#P10329. [UESTCPC 2024] Add

[UESTCPC 2024] Add

Problem Description

Given a sequence a1,a2,,ana_1, a_2, \ldots, a_n of length nn, initially ai=ia_i = i. Perform n1n - 1 operations on this sequence. In the ii-th operation, choose an integer jj uniformly at random from [1,ni][1, n - i], and set aja_j to aj+2ani+1a_j + 2a_{n - i + 1}.

After all operations are finished, compute the expected value of a1mod 998244353a_1 \bmod\text{ }998244353.

Input Format

The first line contains a positive integer TT (1T104)(1 \leq T \leq 10^4), the number of test cases.

The next TT lines each contain a positive integer nn (1n109)(1 \leq n \leq 10^9), representing the length of the sequence.

Output Format

Output TT lines. Each line contains one integer, the expected value of a1mod 998244353a_1 \bmod\text{ }998244353.

3
4
2
5
30
5
55
3
4
3
5
30
14
55
3
8
1
3
204
1
14

Hint

Translated by ChatGPT 5