P26306 [AtCoder] 123 Pairs
NOI
题目描述

Problem Description

Consider integers between $1$ and $2N$. Snuke wants to divide these integers into $N$ pairs satisfying the following conditions:

  • Each integer between $1$ and $2N$ is included in exactly one pair.
  • There are exactly $A$ pairs with a difference of $1$.
  • There are exactly $B$ pairs with a difference of $2$.
  • There are exactly $C$ pairs with a difference of $3$.

Due to the constraints, it is guaranteed that $N = A + B + C$, so there are no pairs with a difference of $4$ or more.

Find the number of ways to divide these pairs, modulo $10^9+7$.

Input Format

The input is given from the standard input in the following format:

$ N $ $ A $ $ B $ $ C $

Output Format

Output the answer.

Sample Input and Output

Sample Input #1

3 1 2 0

Sample Output #1

2

Sample Input #2

600 100 200 300

Sample Output #2

522158867

Notes/Hints

Constraints

  • $1 \leq N \leq 5000$
  • $0 \leq A, B, C$
  • $ A + B + C = N $

Sample Explanation 1

There are two ways: $1-2, 3-5, 4-6$ and $1-3, 2-4, 5-6$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 1 2 0
样例输出
2