Dice Game

아직 제출이 없습니다시간 제한5초메모리 제한1024 MB

문제

Putata and Budada are playing an interesting game. They play this game with a die having nn faces. Every integer between 00 and n1n-1 are written on exactly one face, and when they roll this die, each side will face up with equal probability. In other words, rolling the die will result in a uniform random integer between 00 and n1n-1 with equal probability.

The game has two rounds. In the first round, the following happens:

  • Putata will roll the die and get an integer as the result, say xx.

In the second round, Budada can choose to do one of the following things:

  • End the game, and the score of the game will be xx.
  • Roll the die again, let the result be yy, and the game will end, the score of the game will be xyx \oplus y. Here \oplus denotes binary exclusive-or operation.

Putata and Budada want to maximize the score of the game, and they are so clever that they will always make the best choice. Please write a program to calculate, for some given nn, the expectation of the score of the game.

It can be shown that the answer can be expressed as an irreducible fraction xy\frac{x}{y}, where xx and yy are integers and y≢0(mod998,244,353)y \not \equiv 0 \pmod {998\\,244\\,353}. Output the integer equal to xy1(mod998,244,353)x\cdot y^{-1}\pmod {998\\,244\\,353}. In other words, output such an integer aa that 0a<998,244,3530\leq a < 998\\,244\\,353 and ayx(mod998,244,353)a\cdot y\equiv x\pmod {998\\,244\\,353}.

입력

The input contains several test cases. The first line contains an integer TT (1T1041 \leq T\leq 10^4).

For the following TT lines, each line contains an integer nn (1n998,244,3521\leq n\leq 998\\,244\\,352), denoting one question.

출력

Output TT lines, each line denotes the answer for one test case.