- Time limit: 1.00 s
- Memory limit: 512 MB
Your task is to calculate binomial coefficients modulo .
A binomial coefficient can be calculated using the formula . We assume that and are integers and .
Input
The first input line contains an integer : the number of calculations.
After this, there are lines, each of which contains two integers and .
Output
Print each binomial coefficient modulo .
Constraints
Example
Input:
3 5 3 8 1 9 5
Output:
10 8 126