BETA

Submissions : 514 Accuracy :

6.03

nCr mod M | Part 1
       

Given 3 integer N,R and M. You task is to calculate NCR%M.

Input:

The first line of the input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of 3 integers N,R and M.


Output:
For each test case output a single integer representing the value of NCR%M

Constraints :

1<=T<=100
1<=R<=N<=10^16
M=10^6+3

Example:

Input:
3
4 2 1000003
3 1 1000003
5 3 1000003

Output:
6
3
10

**For More Examples Use Expected Output**


Contributor: Pranay Pandey

Set Default Code

					   
Result:
It is recommended to test your code before clicking 'Submit' button!



                   



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.