#P7704. [2019年杭电多校]permutation 2
[2019年杭电多校]permutation 2
permutation 2
Problem Description
You are given three positive integers . Please calculate how many permutations of satisfies the following conditions (We denote the -th number of a permutation by ):
- for all ,
Input
The first line contains one integer denoting the number of tests. For each test, there is one line containing three integers .
Output
For each test, output one integer in a single line indicating the answer modulo .
Sample Input
3
4 1 4
4 2 4
100000 514 51144
Sample Output
2
1
253604680
Source
2019 Multi-University Training Contest 5