MACHMAY  Machine Mayhem
It's the year 4224 and Giant Machine Corporation has started working on its 42nd Generation Robots. These robots are designed to have peculiar specifications.
The company has N different parts (numbered from 1 to N), each of which impart a very specific property to the robot. The formation of a single robot R consists of M steps. At the i^{th} step, one of the N parts is chosen and added to the current robot. After the M^{th} step, the robot is ready. Let num(i, j) be the count of part number j until the i^{th} step used for making the robot R.
The 41st Generation Robots were found to be defective in the sense that one of their properties overshadowed their other properties significantly. Hence, for the 42nd Generation, it was decided that for any robot R, num(i, j) – num(i, k) ≤ 2 for every 1 ≤ i ≤ M and for every pair of j, k where 1 ≤ j, k ≤ N.
Now, the Giant Machine Corporation is interested to know the number of different 42nd Generation Robots that they can make which satisfy the above criteria and hence they have hired you for the task. Since, this number can be very large, output the result modulo 10^{9} + 7.
Note: Two robots R1 and R2 are considered different, if a different part is used in any of the corresponding i steps out of M steps.
Input
The first line starts with an integer T, denoting the number of test cases. T lines follow with each line consisting of two space separated integers M and N.
Output
For each test case, print in a single line the required number.
Constraints
1 ≤ T ≤ 20
1 ≤ N ≤ 50
1 ≤ M ≤ 10^{18}
Example
Input: 3 1 1 2 2 3 2 Output: 1 4 6
Problem Setter: Vivek Hamirwasia.
hide comments
Vivek H.:
20140208 13:06:09
@Mitch Schwartz : Yes, that is right. 

Mitch Schwartz:
20140208 09:13:01
To clarify, we can use the same part multiple times in a given robot, and num(i,j) is the number of times we have used part j after step i. Last edit: 20140208 06:24:18 
Added by:  darkshadows 
Date:  20140128 
Time limit:  1s2s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 