Problem E

Statement
Copy Copied
E. Sets of Complementary Sumstime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputWe call a set of integers $$$Q$$$ a set of complementary sums if it can be obtained through the following actions:  choose an array $$$a$$$ consisting of $$$m$$$ positive integers ($$$m$$$ is any positive integer);  calculate the sum $$$s$$$ of all elements in the array $$$a$$$;  for each element $$$a_{i}$$$ in the array, add the number $$$s - a_{i}$$$ to the set, more formally the set $$$Q = \{s - a_{i}\;|\; 1 \le i \le m\}$$$. Note that $$$Q$$$ is not a multiset, meaning each number in it is unique. For example, if the array $$$a = [1, 3, 3, 7]$$$ was chosen, then $$$s = 14$$$ and $$$Q = \{7, 11, 13\}$$$.Your task is to count the number of distinct sets of complementary sums for which the following holds:  the set contains exactly $$$n$$$ elements;  each element of the set is an integer from $$$1$$$ to $$$x$$$. Two sets are considered different if there exists an element in the first set that is not included in the second set.Since the answer can be huge, output it modulo $$$998\,244\,353$$$.InputEach test consists of several test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^{4}$$$) — the number of test cases. The description of the test cases follows.The only line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n, x \le 2 \cdot 10^{5}$$$).Additional constraints on the input data:  the sum of $$$n$$$ across all test cases does not exceed $$$2 \cdot 10^{5}$$$;  the sum of $$$x$$$ across all test cases does not exceed $$$2 \cdot 10^{5}$$$. OutputFor each test case, output a single integer — the answer to the problem modulo $$$998\,244\,353$$$.ExampleInput51 72 53 1027 314151000 999Output7
10
34
605089068
0
NoteFor the first test case, there are exactly $$$7$$$ suitable sets:$$$$$$\{1\}, \{2\}, \{3\}, \{4\}, \{5\}, \{6\}, \{7\}$$$$$$For the second test case, there are $$$10$$$ suitable sets:$$$$$$\{1, 2\}, \{1, 3\}, \{1, 4\}, \{1, 5\}, \{2, 3\}, \{2, 4\}, \{2, 5\}, \{3, 4\}, \{3, 5\}, \{4, 5\}$$$$$$