#nt601. 组合数取模3
组合数取模3
Binomial Coefficient Modulo (3)
Problem Description
Given a prime . Answer queries; for each, output the value of .
Input Format
The first line contains two integers .
The following lines each contain two integers .
Output Format
For each query, output one line containing the answer.
Sample Input
10007 3
5 2
50 20
50000000 20000000
Sample Output
10
2551
0
Constraints
For all data, , , and are guaranteed, where is prime.