Under construction

Still being built. Things may change

Zig-zag

Time limit12sMemory limit1024 MB

Summary
Count the zig-zag compositions of n into positive parts, where sizes alternate up-down or down-up, for many n up to 300000, modulo 998244353.
Level

Medium7 of 10

Topics
Dynamic programming, Combinatorics
Solved
No attempts yet

Problem

Zack's Zergonomics Zegree has taught him that the optimal way to display items in a store is to stack them into a zig-zag pattern.

Zack needs to display nn boxes lined up on the storefront, each containing an action figure. The boxes can be stacked on top of one another. They are identical and indistinguishable. He must decide the number of stacks, then stack the boxes so that each stack is non-empty and the stack sizes form a zig-zag sequence.

Formally, suppose there are ss (s≥1s \ge 1) stacks numbered 11 to ss from left to right, and stack ii holds aia_i boxes. The following must hold:

  • ai≥1a_i \ge 1 for each ii from 11 to ss.
  • a1+a2+⋯+as=na_1 + a_2 + \dots + a_s = n.
  • At least one of the following is true:
    • a1<a2>a3<a4>…a_1 < a_2 > a_3 < a_4 > \dots
    • a1>a2<a3>a4<…a_1 > a_2 < a_3 > a_4 < \dots

For example, when n=6n = 6, there are 12 ways, as shown in Figure M.1.

Figure M.1: All 12 possible ways for n=6n = 6.

Two ways are the same if and only if they have the same number of stacks and the stacks at each position hold the same number of boxes.

Find the number of different ways Zack can stack nn boxes, modulo 998 244 353998\,244\,353.

Input

The first line contains one integer tt (1≤t≤300 0001 \le t \le 300\,000), the number of test cases. Each of the next tt lines contains one integer nn (1≤n≤300 0001 \le n \le 300\,000).

Output

For each test case, output the number of different ways to stack nn boxes, modulo 998 244 353998\,244\,353, on its own line.

Examples1

  1. Example 1

    Input
    4
    5
    6
    7
    890
    
    Expected output
    7
    12
    19
    502674609