Yummy Pie

All submissions for this problem are available.
Problem description
Golu and Bholu are two close friends who live in Chocolate land. Golu has a big grocery shop in Chocolate land. In his shop, there are "N" boxes, numbered 1 through N. Each box numbered "i" contains exactly "i" Yummy Pies and one eclair. Overall, there are "i+1" chocolates in box "i". Everyday, Golu picks one chocolate from every box uniformly and make a random collection of "N" chocolates for putting it in display. Golu's friend Bholu likes Yummy Pie very much. Since Bholu could not get Yummy pie in any other grocery shop .So One day Bholu planned to visit Golu’s shop for buying "k" Yummy Pies. But,Bholu assumes that whatever things are in display of the shop are the only things present in shop. Being a close friend of Golu, Bholu always pays him a special amount for buying Yummy Pies which equals "p*(N+1)!", where "p" is the probability that collection of "N" chocolates in display will contain exactly "k" Yummy Pies. You being good in mathematics, will help find the amount that Bholu will pay.
Note: Express the amount in modulo 10^9 + 7.
Input
First line of input contains a number "T" denoting number of test cases. First line of each test case contains two space separated integers "N" and "k", denoting number of boxes and number of Yummy Pies Bholu wants exactly.
Output
For each test case, output the required amount (modulo 1000000007) on a separate line.
Constraints
 1 ≤ T ≤ 10
 0 ≤ N ≤ 1000000000
 1 ≤ K ≤ 2000
Example
Input: 3 2 1 3 2 10 4 Output: 3 11 157773
Explanation
Example Case 1:We have two boxes: box 1 with a Yummy Pie and a eclair, and box 2 with two Yummy Pies and a eclair. We are looking for the probability of drawing exactly one Yummy Pie. This can happen in two different ways: either we draw the Yummy Pie from box 1 and the eclair from box 2, or vice versa. The probability of the first way is (1/2)*(1/3) = 1/6. The probability of the second way is (1/2)*(2/3) = 1/3. Thus, the total probability is p = 1/6 + 1/3 = 1/2. We have p * (N+1)! = p*6 = 3, therefore the answer is (3 mod 1,000,000,007) = 3.
Author:  dwij28 
Tags  dwij28 
Date Added:  19042017 
Time Limit:  3 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions