7489: Paperfolding

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:19 通过:12

题目描述

There is a piece of paper in rectangular shape with sufficient length and width (lay flat on the table). Execute an operation instruction according to a string of length n from left to right that only contains 4 different characters of L,R,U,D.

1. L instruction means to fold it from left to right,

2. R instruction means to fold from right to left,

3. U instruction means to fold from top to bottom,

4. D instruction means to fold in half from bottom to top.

Note that the operation is limited due to the limitation of the desktop. Namely, the fold operation is restricted. For example, if you fold the paper from left to right, you should let the left side overlap on the right side with no rotation.

Now, cut a knife horizontally (completely cut) at the center of the visible part of the paper, and then cut vertically (completely cut).

The number of pieces of the whole paper split is num(S).

See the example and the picture for better understanding.

Now given a nonnegative integer n, the string S is generated from 4n different possible outcomes in equal probability. Find the expected value of the number of pieces of the paper which is split, that is E(num(S)) mod 998244353.

It can be shown that the answers can be represented by PQ, where P and Q are coprime integers, and print the value of P×Q−1 mod  998244353.

输入格式

The first line contains a single integer T (1≤T≤105), the number of testcases.

Each of the next T lines contains a number n ( 0≤n≤1018 ).

输出格式

For each testcase, print the answer in one line.

输入样例 复制

2
0
1

输出样例 复制

4
6