#K10396. Unique Word Permutations

    ID: 23237 Type: Default 1000ms 256MiB

Unique Word Permutations

Unique Word Permutations

Given two integers A and L, you are required to count the number of unique words of length L that can be formed using the first A letters of the English alphabet, with each letter used at most once. In other words, you need to compute the permutation P(A, L) which is defined by the formula:

$$P(A, L)=\frac{A!}{(A-L)!}$$

If L is greater than A, then no valid word can be formed and the answer is 0. Your task is to process several test cases and output the corresponding values.

inputFormat

The input begins with an integer T, representing the number of test cases. Each of the following T lines contains two space-separated integers A and L, where A denotes the number of letters available from the beginning of the alphabet and L denotes the length of the word you want to form.

outputFormat

For each test case, output a single line containing a single integer the number of unique words that can be formed. If it is impossible to form such a word (i.e., when L > A), output 0.

## sample
2
3 2
4 3
6

24

</p>