#C11409. Permutations Calculation
Permutations Calculation
Permutations Calculation
Given two integers n and r, compute the number of permutations of n items taken r at a time. The number of permutations is defined by the formula:
$$P(n, r) = \frac{n!}{(n - r)!}$$
Since the factorial values can be huge, compute the result modulo 1000000007.
Note that if r > n, the result is defined as 0. Also, by convention, P(n, 0) = 1.
inputFormat
The first line of the 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 r.
outputFormat
For each test case, output a single line containing the number of permutations modulo 1000000007.
## sample4
5 3
4 4
10 0
10 10
60
24
1
3628800
</p>