P29199 [洛谷] The Witch's Tea Party
提高-
题目描述

Problem Background

"So that's the root of your desire, how intriguing..."

The voice echoed through the tomb, and Subaru turned abruptly, only to find the scene before him drastically changed: the dark walls around him had transformed into an endless meadow with rolling hills of various sizes; where the entrance to the tomb should have been, there was now a tea table with two chairs, all under the shade of a parasol, and a black-clad woman seated there.

First Encounter

"It's been a long time since I've conversed with a human, I got a bit excited... My name is Echidna. 'The Greed Witch,' that's easier to understand, right?" the woman said with a faint smile.

"Where am I!? I should be in a dark ruin, when did you transfer me here?" Subaru clenched his teeth and asked.

"Unfortunately, you're mistaken. You haven't physically been transferred, you've just been invited to my tea party."

"A tea party...?"

"Yes, a witch's tea party."

[Admin Mivik altered the timeline]

Problem Description

"So... how long are you going to stand there? Sit down before the tea gets cold."

"Ugh... fine, fine!" Subaru approached and sat opposite the witch. In addition to the two cups of tea, there was a chessboard with black and white squares.

"What's this...?" Subaru pointed at the chessboard and asked.

"This is Witch Chess. I invited you here to solve a problem that has puzzled me for many years. If you solve it, I'll grant you and Emilia the right to undergo the trials... otherwise..." An unsettling smile appeared on the witch's face, "You might end up endlessly轮回 in the Sanctuary...?"

Subaru broke out in a cold sweat and asked nervously, "So what's the problem?"

The witch picked up a piece from beside her and slowly said, "As you can see, this is an $n \times n$ chessboard, consisting of $n^2$ squares, each of which can hold at most one piece. Unlike a regular chessboard, this one is cyclic, meaning that the square at the $n$th column of the $i$th row is next to the square at the 1st column of the $i$th row, and similarly, the square at the $i$th row of the $n$th column is below the square at the 1st row of the $i$th column, and so on. The piece I hold is called the 'Sin Archbishop,' which can move any number of squares diagonally. A square that a piece can reach in one move is considered under its control. If a piece controls the square where another piece is located, the board layout is unstable; otherwise, it is stable. Now, can you place exactly $m$ 'Sin Archbishops' on the board such that the entire layout is stable?"

Example

High-res version of the above image

Subaru pondered for a moment, then operated on the board and quickly completed the witch's task, saying, "Now, quickly give me the right to undergo the trials!"

The witch said, "Not yet... I still have one problem unsolved..."

Subaru: "Come on, you're cheating!"

The witch ignored Subaru and continued, "Now the question is, how many fundamentally different stable layouts are there, such that there are exactly $m$ 'Sin Archbishops' on the board? Two layouts are considered fundamentally different if there is at least one square that has a piece in one layout and none in the other."

Subaru got even angrier because he couldn't solve it and turned to you for help. You just need to tell him the result modulo $998244353$.

Input Format

A line containing two positive integers $n, m$, representing the size of the chessboard and the number of pieces you need to place.

Output Format

A line containing a positive integer, representing the result modulo $998244353$.

Sample Input and Output

Sample Input #1

1 1

Sample Output #1

1

Sample Input #2

2 2

Sample Output #2

4

Sample Input #3

3 2

Sample Output #3

18

Sample Input #4

10 5

Sample Output #4

8647680

Notes

Sample 1: Placing one piece on a $1 \times 1$ board obviously has only one solution.

Sample 2: There are four stable layouts (using . for empty spaces and o for 'Sin Archbishops'):

oo .o .. o.
.. .o oo o.

Sample 3: All 18 stable layouts can be viewed here.

Data Range

For all data, $1 \le n < 998244353$, $0 \le m \le \min\{n, 10^7\}$.

Subtask 1 (5 pts): Guaranteed $m = 0$.

Subtask 2 (10 pts): Guaranteed $m = 1$.

Subtask 3 (10 pts): Guaranteed $1 \le n \le 4$.

Subtask 4 (20 pts): Guaranteed $n$ is odd.

Subtask 5 (25 pts): Guaranteed $n \le 10^7$.

Subtask 6 (30 pts): No special restrictions.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 1
样例输出
1