nCr mod M | Part 1
Hard Accuracy: 12.13% Submissions: 1415 Points: 8

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

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.