#Q230. 「一本通 6.6 例 3」组合

「一本通 6.6 例 3」组合

Description

The combinatorial number C(n,m)C(n,m) represents the number of ways to choose mm elements from a set of nn elements. For example, C(5,2)=10C(5,2) = 10 and C(4,2)=6C(4,2) = 6. However, when nn and mm are relatively large, C(n,m)C(n,m) becomes very large. Therefore, xiaobo asks you to output the value of C(n,m)modpC(n,m) \bmod p.

Input Format

The first line of input is a positive integer TT, representing the number of test cases;

Next, there are TT test cases, each consisting of three positive integers n,m,pn, m, p.

Output Format

For each test case, output a positive integer representing the result of C(n,m)modpC(n,m) \bmod p.

Sample 1

2
5 2 3
5 2 61

1
10

Data Range and Hints

For all data, T100T\le 100, 1mn1091\le m\le n\le 10^9, m104m\le 10^4, m<p<109m\lt p\lt 10^9, and pp is a prime number.