B. Bored Brother
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output

Towers of Hanoi is a game where you have $$$n$$$ disks of different sizes and three rods. To start out, all disks are stacked on the first rod, such that the largest disk is at the bottom and going up the pile, each disk is smaller than the one below it. The goal is to move all disks to the last rod. In any given move, you are only allowed to move one disk from the top of one pile to the top of another. At any time, it has to hold that for two disks on top of each other, the upper one has to be smaller than the lower one. If this condition is fulfilled, we call the current state a valid game state.

This weekend you are in charge of babysitting your little brother. As he has a tendency to wreak havoc on your house once he is bored, you want to keep him occupied. In order to do so, you are playing Towers of Hanoi with him, but he has not quite understood the rules yet. In order to help him, you will at any time cover one of the three piles with your hand. Your brother will then randomly pick one of the two remaining piles and move the uppermost piece to the other pile (if one of the piles is empty, he cannot pick from this pile). You can only move your hand to a different pile when you are in a valid game state. If you optimally decide which pile to cover at any time, calculate is the expected number of moves your brother will make until he has moved all $$$n$$$ pieces from the first to the last pile such that they are stacked in increasing size from bottom to top.

If this process is not clear, the sample explanation may help.

Input

The first line contains one number $$$t$$$ ($$$1 \leq t \leq 10^5$$$), the number of test cases. Each test consists of one integer $$$n$$$ ($$$1 \leq n \leq 10^{12}$$$), the number of disks.

Output

For each test, output one number, the expected number of moves modulo $$$M = 998\,244\,353$$$.

It can be shown that the answer can be expressed as an irreducible fraction $$$\frac{p}{q}$$$ where $$$q \not \equiv 0 \ \operatorname{mod} M$$$. Output $$$p \cdot q^{-1}\ \operatorname{mod} M$$$. In other words output $$$0 \leq x \lt M$$$ such that, $$$x \cdot q \equiv p \ \operatorname{mod} M$$$.

Example
Input
4
1
2
4
2759
Output
1
5
41
823845074
Note

In the following, we will show the optimal strategy for $$$n = 2$$$. It can be proven that covering another pile at any time will lead to a larger expected number of moves.

Initially, both disks are on the first pile, with the smaller one on top.

We will cover the third pile with our hand.

Thus, the two uncovered piles are one and two. As there are no disks on the second pile, the little brother will choose to move the upper most disk from the first pile to the second pile. This is his first move.

After this, we are in a valid game-state and are thus allowed to move our hand. We will do so, now covering the second pile.

Once again, the little brother will move the disk from pile one to pile three, as he has no other move. This is his second move.

Now we are in a valid game state once again. This time we will move our hand to cover the first pile.

This leaves the brother with two possible moves: he either moves the disk from the second to the third pile or the disk from the third to the second pile.

In the first case, we are done in three moves.

   

In the second case, we cannot move our hand, as we are in an invalid gamestate, and can thus only wait for our brothers fourth move, returning us to the previous state.

Even though we are once again in a valid state, we will not move our hand. It can be shown that it is optimal to not move our hand from this point onward. In expectation, resolving this state will take our brother $$$3$$$ moves, giving us the final answer of $$$2+3 = 5$$$ moves.