P15706 [JAG 2023 Summer Camp #2] Sum of Product of Binomial Coefficients

Description

You are given integers $N$ and $K$. For a positive integer $k$, $f(k)$ is defined as follows. * The sum of $\binom{N}{a_1} \times \binom{a_1}{a_2} \times \cdots \times \binom{a_{k-1}}{a_k}$ for all integer sequences $(a_1, a_2, \ldots, a_k)$ that satisfy the condition $N \ge a_1 \ge a_2 \ge \ldots \ge a_k \ge 0$. Answer the remainder of $\sum_{k=1}^{K} f(k)$ divided by $998244353$. For each input, solve $T$ test cases. Note that $\binom{A}{B}$ represents "the number of ways to select $B$ distinct items from $A$ items" (i.e., the binomial coefficient).

Input Format

$$ \begin{aligned} & T \\ & \text{case}_1 \\ & \vdots \\ & \text{case}_T \end{aligned} $$ Each test case is given in the following format. $$N \quad K$$ The input satisfies the following constraints. * All test cases consist of integers. * $1 \le T \le 10^5$ * $0 \le N \le 10^9$ * $1 \le K \le 2 \times 10^5$ * The sum of $K$ in one test case does not exceed $2 \times 10^5$.

Output Format

Output the remainder of $\sum_{k=1}^{K} f(k)$ divided by $998244353$ for each test case.