Time limit: 0.4s
Memory limit: 128MB
Input: combination.in
Output: combination.out
Task
You are given queries. For each of the queries you are given two integers, and . Calculate , where represents the number of ways to choose values from a set of ( choose ).
Input data
On the first line of the input file combination.in
you have , the number of queries. On each of the following lines you will have and .
Output data
For each of the questions we will print the answer in the output file combination.out
. Because these numbers can be very large, you will need to print them modulo .
Constraints and clarifications
- is a prime number.
# | Points | Constraints |
---|---|---|
0 | 0 | Example |
1 | 20 | |
2 | 40 | |
3 | 40 | No additional constraints |
Example
combination.in
11
7 5
35 20
85 40
67 40
44 7
76 69
60 35
44 43
28 20
44 13
93 17
combination.out
21
247943139
221670461
845448992
38320568
186189386
610920233
44
3108105
915526075
419070982
Explanation
.