WATER GUN

3.2

13 votes
Very-Easy
Problem

Anmol and Biswa have got a water gun with colored pellets to hit Anurag as they have too much free time this semester. The pellets can be of K different colors. They have infinite pellets for each color. The water gun has only two slots for pellets, both of which get fired simultaneously(i.e., the order of pellets in the refill does not matter). So they'll have to refill it a number of times. On each refill, they must choose two pellets, which must be of different colors. They aren't worried about that though, as both of them have whole of their afternoon free now.
Now, they decided to refill the gun N times, and want each refill be such that any pair of refill of pellets out of those N has atleast one color in common between them. They now start wondering how many such ordered sets of refills exist.
Mathematically, the refills, Ri are such that, R1,R2,...,RN,|Ri|=2,Ri {1,2,...K} and RiRjΦ for any distinct i,j [1,2,..N] .

Note: Print the number of such ordered sets of refills modulo 1000000007.

Input

  • The first line contains a single integer T, denoting the number of test cases.
  • Next T lines contain two space separated integers K and N denoting the number of colors for the pellets and number of refills respectively.
Output
  • For each test case, you need to output a single integer in a new line.
Constraints
  • 1 ≤ T ≤ 1000
  • 1 ≤ N ≤ 5000
  • 1 ≤ K ≤ 5000

Sample Input
2
2 2
3 2
Sample Output
1
9
Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?