#P3862. 数圈
数圈
Description
Compute the number of cycles in the undirected complete graph on vertices after deleting one edge, and output the answer modulo .
Note: A “cycle” means choosing any vertex as the starting point, following non-repeating edges, visiting non-repeating vertices along the way, and then returning to the starting vertex to form a closed path.
Input Format
The first line contains an integer , indicating the number of test cases.
The next lines each contain an integer , as described above.
Output Format
Output lines, each containing one integer, representing the answer.
4
3
4
5
6
0
3
22
133
Hint
For the first of the testdata, .
For an additional of the testdata, .
For an additional of the testdata, .
For the remaining of the testdata, .
All testdata satisfy .
Translated by ChatGPT 5
京公网安备 11011102002149号