Four Square Tiles

AtCoder
IDarc197_e
Time2000ms
Memory256MB
Difficulty
You are given positive integers $N$, $H$, and $W$, with $H,W \le 3N-1$. Find the number, modulo $998244353$, of ways to place four $N\times N$ square tiles on an $H\times W$ grid that satisfy all of the following conditions. * Each tile exactly covers $N^2$ cells of the grid. * No cell is covered by more than one tile. Here, the tiles are indistinguishable. There are $T$ test cases; solve each one. ## Constraints * $1\le T\le 2\times 10^5$ * $1\le N,H,W\le 10^9$ * $H,W\le 3N-1$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $T$ $\text{case}_1$ $\vdots$ $\text{case}_T$ Each case is given in the following format: $N$ $H$ $W$ [samples]
Samples
Input #1
4
2 4 5
2 5 5
1000 1000 1000
1000 2222 2025
Output #1
9
79
0
262210557

For the first test case, there are $9$ ways as illustrated in the following figure:
![image](https://img.atcoder.jp/arc197/240d39425cb3786e6c8a2952f2220f14.png)
API Response (JSON)
{
  "problem": {
    "name": "Four Square Tiles",
    "description": {
      "content": "You are given positive integers $N$, $H$, and $W$, with $H,W \\le 3N-1$. Find the number, modulo $998244353$, of ways to place four $N\\times N$ square tiles on an $H\\times W$ grid that satisfy all of t",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc197_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given positive integers $N$, $H$, and $W$, with $H,W \\le 3N-1$.\nFind the number, modulo $998244353$, of ways to place four $N\\times N$ square tiles on an $H\\times W$ grid that satisfy all of t...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments