Fifty Shades Of Grey

0

0 votes
Problem

Christian Grey has met Anastasia Steele( Ana ) and took her on first date.He said to Ana that he would tell her something on their first date.So as promised he took her to his home at Seattle.After reaching home Ana could not resist herself so she asked about the thing that he wanted to tell,he took her by her hand and took her to the RED PLAYROOM and presented a contract that qoutes HARD LIMITS( things that he will not do with her ) and SOFT LIMITS( things that he can do).She wanted to negotiate so he gave her time to think about.They met again next sunday and Ana told him that she is willing to be his submmisive only for three soft limits.

Now Grey agrees with the Ana and tells her that they would meet N times over a month and she would be his submissive. She agrees but she also tells him the number of times he could execute a particular soft limit.As Grey was slowly falling in love with her he agrees.

So at last what concludes that she will be his submissive for N times and every time he will execute atleast one of three soft limits and he can execute any soft limit only once each time.

Ana tells him that it is not possible for her to leave before leaving her desires unfullfilled so they must execute all number of soft limits in exactly N meetings.

Then Grey met Mrs. Robinson and tells her about the agreement.As he was her past submmisive she wants to know in how many ways he could use his playroom to execute all the soft limits in N number of times.

Input :
T denoting number of test cases there will be 4 numbers corresponding to every test case

N Number of times they will meet in a month
x y z Number of times she would submit her for soft limit 1,2 and 3 respectively.

Output :
Answer corresponding to question as answer could be very large take modulo with 10^9+7.

Constraints :

  • 1<= T <= 70
  • 1 <= N <= 50
  • 1 <= x,y,z <=50

Sample Input:

2
3 3 3 3
3 2 1 1

Sample Output:

1
15

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?