Loading...
Circle of Harmony
Time: 1 s
Memory: 125 MB
You are given a set of n distinct elements labeled from 1 to n, arranged in a circle in clockwise order.
Define a function \(f(k)\) as the number of ways to partition this set into exactly k non-empty groups such that :
  • Each element belongs to exactly one group.
  • For each group, if you draw straight line segments (chords) connecting every pair of elements within that group inside the circle,
  • Then, no two chords from different groups intersect each other inside the circle.
Two ways of partitioning are considered different if there exists at least one element that belongs to different groups in the two partitions.
Your task is to compute the value of : \(\sum_{k=1}^{n} f(k) \)

—that is, the total sum of \(f(k)\) for every k from 1 to n.
Since the answer can be very large, output the result modulo 998244353
Input
The first line contains an integer T — the number of test cases.
Each of the next T lines contains a single integer n — the size of the set.
Constraint
\(1 \leq T \leq 10^5\)
\(1 \leq n \leq 10^6\)
Output
For each test case, output a single line containing one integer — the answer to the given test case
Examples
Input
Output
3
1
3
5
1
5
42
Input
Output
3
9
24
15
4862
172443248
9694845
Problem Info
Problem ID 428
Time Limit 1000 ms
Memory Limit 128000 KB
Moderators Royboy01 , Alom_Shanto
Statistics
Submit
You need to Login or Registration for submit your solution