F. Funny Permutations

Time limit: 0.3sMemory limit: 256MBInput: Output:

Let p=(p1,p2,…,pn)p = (p_1, p_2, \ldots, p_n) be a permutation of {1,2,…,n}\{1, 2, \ldots, n\}.
For every index 1≤i≤n1 \le i \le n, define

pg⁡(i)={max⁡{ j∣1≤j<i, pj>pi }if such a j exists,−1otherwise.\operatorname{pg}(i) = \begin{cases} \max\{\, j \mid 1 \le j < i,\ p_j > p_i \,\} & \text{if such a } j \text{ exists},\\[2pt] -1 & \text{otherwise.} \end{cases}

The funniness of a permutation pp is

f(p)=∑i=1npg⁡(i).f(p) = \sum_{i=1}^{n} \operatorname{pg}(i).

Given nn, compute

∑p∈Snf(p)(mod998 244 353),\sum_{p \in S_n} f(p) \pmod{998\,244\,353},


where SnS_n is the set of all n!n! permutations of {1,2,…,n}\{1, 2, \ldots, n\}.

Input

The first line contains a single integer tt (1≤t≤1061 \le t \le 10^6), the number of test cases.

Each of the next tt lines contains a single integer nn (1≤n≤1061 \le n \le 10^6).

Output

For each test case, print a single line containing ∑p∈Snf(p)\sum_{p \in S_n} f(p) modulo 998 244 353998\,244\,353.

Exemplul 1

stdin

3
3
10
2048

stdout

998244352
108328320
887633861

Note

In the first test case, n=3n = 3. The six permutations of {1,2,3}\{1, 2, 3\} are:

pp pg⁡(1)\operatorname{pg}(1) pg⁡(2)\operatorname{pg}(2) pg⁡(3)\operatorname{pg}(3) f(p)f(p)
(1,2,3)(1, 2, 3) −1-1 −1-1 −1-1 −3-3
(1,3,2)(1, 3, 2) −1-1 −1-1 22 00
(2,1,3)(2, 1, 3) −1-1 11 −1-1 −1-1
(2,3,1)(2, 3, 1) −1-1 −1-1 22 00
(3,1,2)(3, 1, 2) −1-1 11 11 11
(3,2,1)(3, 2, 1) −1-1 11 22 22

For example, in p=(3,1,2)p = (3, 1, 2), the nearest element to the left of position 33 that is greater than p3=2p_3 = 2 is p1=3p_1 = 3, so pg⁡(3)=1\operatorname{pg}(3) = 1.

The total is −3+0−1+0+1+2=−1-3 + 0 - 1 + 0 + 1 + 2 = -1, and −1≡998 244 352(mod998 244 353)-1 \equiv 998\,244\,352 \pmod{998\,244\,353}.

Log In or Sign Up to be able to send submissions!