問題一覧 > 通常問題

No.2529 Treasure Hunter

レベル : / AI推定難易度 : 1450 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 96
作問者 : PCTprobability / テスター : NyaanNyaan
お気に入りにしたユーザー ProblemId : 7174 / 自分の提出
問題文最終更新日: 2023-11-03 22:15:19
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 411 オムニバスコンテスト (順位表) の他の問題:

Problem Statement

PCT has become the creator god of a world built on an $M \times N$ grid.

Below, the cell in the $i$-th row from the top and the $j$-th column from the left is called $(i,j)$.

He has decided to choose some cells in this world and bury treasures in them so that all of the following conditions are satisfied.

  • At most $1$ treasure can be buried in each cell.
  • At most $2$ treasures can be buried in each row.
  • Cells in which treasures are buried must not be adjacent to each other. Here, in this world, $(i,1)$ and $(i,N)$ are considered adjacent.

Find the number of ways to bury the treasures satisfying the conditions, modulo $998244353$.

$T$ test cases are given; find the answer for each of them.

Constraints

  • All inputs are integers.
  • $1 \le T \le 2 \times 10^5$
  • $2 \le N,M \le 2 \times 10^5$
  • The sum of $N$ over the test cases is at most $2 \times 10^5$.
  • The sum of $M$ over the test cases is at most $2 \times 10^5$.

Input

The input is given in the following format.

$T$
$\mathrm{case}1$
$\vdots$
$\mathrm{case}T$

Each case is given in the following format.

$N\ M$

Output

Output $T$ lines, followed by a newline at the end.
On the $i$-th line, output the answer for the $i$-th test case.

Sample

Sample 1
Input
5
4 2
5 6
123 456
1234 5678
3141 5926
Output
35
276561
532350908
204920481
830272369

For the first test case, for example, an arrangement like Figure $1$ below satisfies the conditions. In Figure $2$, treasures are placed on both $(2,1)$ and $(2,4)$, but it is invalid because they are adjacent.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。