AtCoder Regular Contest 209 (Div. 1)
E
I hate ABC
AtCoder
未评级
原题
← D→
翻译中…

Problem Statement

翻译中…

Find the number, modulo $998244353$, of strings $S$ of length $N$ consisting of A, B, C such that the following value equals $K$:

翻译中…
  • The maximum length of a (not necessarily contiguous) subsequence of $S$ that does not contain ABC as a (not necessarily contiguous) subsequence
翻译中…

You are given $T$ test cases. Solve each of them.

翻译中…

Constraints

翻译中…
  • $1 \le T \le 2 \times 10^5$
  • $1 \le N \le 10^6$
  • $\max(0,N-100) \le K \le N$
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

翻译中…

Each case is given in the following format:

翻译中…

N\ K

翻译中…

Output

翻译中…

Output $T$ lines. The $i$-th line $(1 \le i \le T)$ should contain the answer to the $i$-th test case.

翻译中…

样例

Input #1
4
4 3
8 6
123 100
123456 123400
Output #1
9
462
741573397
255048895
For the first test case, for example, `ACBC` satisfies the condition. `ACBC` itself contains `ABC` as a subsequence, and `ACC` does not contain `ABC` as a subsequence, so the maximum length of a subsequence that does not contain `ABC` as a subsequence is $3$. Other examples that satisfy the condition include `AABC` and `ABCA`.
题目信息
题号
arc209_e
时间限制
4 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。