#P3862. 数圈

数圈

Description

Compute the number of cycles in the undirected complete graph on nn vertices after deleting one edge, and output the answer modulo 998244353998244353.

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 TT, indicating the number of test cases.

The next TT lines each contain an integer nn, as described above.

Output Format

Output TT lines, each containing one integer, representing the answer.

4
3
4
5
6
0
3
22
133

Hint

For the first 10%10\% of the testdata, 3n103 \leq n \leq 10.

For an additional 20%20\% of the testdata, 9.99×102n103 9.99\times 10^2 \leq n \leq 10^3.

For an additional 30%30\% of the testdata, 9.99×104n105 9.99\times 10^4 \leq n \leq 10^5.

For the remaining 40%40\% of the testdata, 9.99×108n109 9.99\times 10^8 \leq n \leq 10^9.

All testdata satisfy 1T101 \leq T \leq 10.

Translated by ChatGPT 5