GOODB - Good Predictions


Having arrived at the ACM-ICPC contest site in a fun-filled mood, The Team continues their important pre-contest preparations. Specifically, every world-class team knows the importance of making predictions about their upcoming submissions.

The Team knows that they'll get plenty of AC (Accepted) submissions, and they find those quite boring by now. As such, they'll focus on their incorrect ones. From their vast experience, The Team knows that they'll only get exactly $N$ ($1 \leq N \leq 300$) submissions wrong throughout the upcoming contest - in fact, they predict that, of those, exactly $W$ ($0 \leq W \leq 100$) will get WA (Wrong Answer), $T$ ($0 \leq T \leq 100$) will get TLE (Time Limit Exceeded), and the remaining $R$ ($0 \leq R \leq 100$) will get RE (Runtime Error). Note that $W+T+R=N$.

Assuming that their predictions will certainly be correct, the members of The Team are wondering in how many ways that might occur. In other words, how many different ordered combinations of $N$ incorrect results (each being WA, TLE, or RE) exist which satisfy their predictions? Since The Team doesn't make many mistakes, surely you can calculate this value, right? However, since it can get quite large for you, compute it modulo ($10^9+7$).

Input

4 integers, $N$, $W$, $T$, and $R$

Output

1 integer, the number of valid ordered combinations of submission results, modulo ($10^9+7$).

Example

Input:
3 2 1 0 

Output:
3

Explanation of Sample:

Out of 3 submissions, two are WA, while the third is TLE. The following 3 ordered combinations are then possible:

WA, WA, TLE

WA, TLE, WA

or

TLE, WA, WA

The answer is then $3$ modulo ($10^9+7$) = $3$.


hide comments
altayeb_10: 2023-02-08 15:42:51

bad problem );

tarun_28: 2020-04-20 11:23:11

use // in case you are using python 3
simple / will give WA for large divisions..

Last edit: 2020-04-20 11:25:05
shubham9261: 2017-08-11 22:48:35

question needs to be corrected as when t=w=r=0 N!=0 as N>=1 hence t+w+r!=N

vikramsr: 2016-10-01 13:20:48

My 50th :)

utkarsh538: 2016-04-26 14:28:50

really simple :)

slim_shah: 2016-04-25 18:10:54

How to view solution of this question ?? i know the formula but i am getting segmentation error

Vicky: 2015-05-14 13:13:08

nice problem ;)


Added by:SourSpinach
Date:2013-05-09
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own problem