#K72612. Taco Ordering
Taco Ordering
Taco Ordering
Chef is hosting a taco party and plans to line up his tacos on a special plate. He has N tacos and a plate that supports a maximum configuration parameter K.
The rules are as follows:
- If K <= 0, the plate is unusable, and the answer is 0.
- If K = 1, the plate can hold exactly one taco. In this case, the ordering is possible only when N = 1; otherwise, the answer is 0.
- If K > 1, Chef can arrange the N tacos on the plate in any order. In other words, the number of valid orderings is given by the factorial of N modulo \(10^9+7\), i.e., \(N! \mod (10^9 + 7)\).
Your task is to compute the number of valid taco orderings based on the given N and K.
Note: All calculations should be performed modulo \(10^9+7\).
inputFormat
The first line of input contains a single integer T representing the number of test cases.
Each of the following T lines contains two space‐separated integers N and K.
Input Format:
T N1 K1 N2 K2 ... NT KT
outputFormat
For each test case, output a single integer representing the number of valid taco orderings as defined in the problem. Each answer should be printed on a new line.
Output Format:
result1 result2 ... resultT## sample
3
3 2
4 3
5 1
6
24
0
</p>