
The first line of input contains an integer ‘T’ denoting the number of test cases.
The next ‘T’ lines represent the ‘T’ test cases.
The first and only line of each test case contains two integers ‘N’ and ‘K’.
For each test case, print a single line containing a single integer denoting the answer for that test case modulo 10^9 + 7.
Print the output of each test case in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= ’T’ <= 50
1 <= ’N’ <= 10000
0 <= ’K’ <= ’N’
Time Limit: 1 sec
Algorithm:
n! = n * (n - 1).....(n - k + 1) * (n - k) * (n - k - 1)...1
n! = n * (n - 1)...(n - k + 1) * (n - k)!
P(n, k) = n * (n - 1)..(n - k + 1)*(n - k)! / (n - k)!
P(n, k) = n * (n - 1) * (n - 2)..*(n - k + 1).
P(n, k) is also given as the product of k terms from n.
Algorithm: