#P7419. 「PMOI-2」参天大树

「PMOI-2」参天大树

Description

b6e0 has a towering tree. This rooted binary tree has infinitely many nodes. The root is numbered 11. For every x(x1)x(x\ge1), the node numbered xx has children numbered 2x2x and 2x+12x+1.

Among the nodes with numbers n\le n, you need to choose two nodes (they may be the same), and find the sum of the numbers of their lowest common ancestors over all choices. That is, compute (where LCA(i,j)\operatorname{LCA}(i,j) denotes the number of the lowest common ancestor of ii and jj):

i=1nj=1nLCA(i,j)\sum_{i=1}^n\sum_{j=1}^n \operatorname{LCA}(i,j)

It is guaranteed that there exists a natural number kk such that n=2k1n=2^k-1.

Take the answer modulo 998244353998244353.

Input Format

This problem has multiple queries.

The first line contains a positive integer tt, the number of queries.

The next tt lines each contain a natural number kk, meaning that in the ii-th query n=2k1n=2^k-1.

Output Format

Output tt lines. The ii-th line should be the answer for the ii-th query modulo 998244353998244353.

2
2
3
12
88

Hint

[Sample Explanation]

For the first query, n=221=3n=2^2-1=3, and the answer is 1+1+1+1+2+1+1+1+3=121+1+1+1+2+1+1+1+3=12.

[Constraints]

This problem uses bundled testdata.

  • Subtask 1 (20 pts): k8k\le8.
  • Subtask 2 (20 pts): t,k300t,k\le300.
  • Subtask 3 (20 pts): k104k\le10^4.
  • Subtask 4 (40 pts): no special constraints.

For 100%100\% of the testdata, 1t,k1061\le t,k\le10^6.

Translated by ChatGPT 5