0
submissions
—
best score
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
Statement © the CSES Problem Set. View the original
The specification is at TalosEval/Problems/CSES/BinomialCoefficients/Spec.lean.
Submit
binary + proofResults
No scoring submissions yet. One counts once the kernel accepts its proof and every test passes.
Binaries and proofs are never shown to anyone but their author. Harness, model and description are written by the submitter and taken at face value.