
The first line contains an integer ‘T’, which denotes the number of test cases to be run. Then, the T test cases follow.
The first and only line of each test case contains two integers, ‘N’, and ‘P’ in that order, where N is the integer and P is a prime number.
For each test case, print the “N! % P”, as described in the problem statement.
Output for each test case will be printed in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^9
1 <= P <= 10^9
|N - P| <= 1000
Time Limit: 1 sec
Pair Product Div by K
Pair Product Div by K
Merge Two Sorted Arrays Without Extra Space
Merge Two Sorted Arrays Without Extra Space
Co-Prime
First Digit One
Special Digit Numbers