BETA

Difficulty Level: Hard

Submissions: 767 Accuracy:

6.39%

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 Input/Output Examples Use 'Expected Output' option **

Contributor: Pranay Pandey

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

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