题目描述
Problem Description
Tuplis-chan loves sequences.
Tuplis-chan currently has a sequence $ A = (1) $ of length $ 1 $.
Tuplis-chan decided to repeat one of the following operations on $ A $ for $ N $ times. Here, let $ a_i $ denote the $ i $ -th element ( $1 \leq i \leq |A|$ ) of the sequence $ A $ from the front.
- Append $ 1 $ or $ M $ to the end of $ A $
- Choose an integer $ i $ such that $1 \leq i < |A|$. Insert an integer $ x $ between $ a_i $ and $ a_{i+1} $ such that $ a_i < x < a_{i+1} $ or $ a_i > x > a_{i+1} $
Let $ S_i $ be the sequence $ A $ after the $ i $ -th operation.
Find the number of possible sequences of sequences $S_1, S_2, \ldots, S_N$ modulo $ 998244353 $.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $
Output Format
Output the number of possible sequences of sequences $S_1, S_2, \ldots, S_N$ modulo $ 998244353 $.
Sample Input and Output
Sample Input #1
2 3
Sample Output #1
5
Sample Input #2
1024 52689658
Sample Output #2
654836147
Notes/Hints
Constraints
- $1 \leq N \leq 3000$
- $2 \leq M \leq 10^8$
Sample Explanation 1
First, append $ 3 $ to the end of $ A $ in the first operation, resulting in $ A = (1, 3) $. Then, in the second operation, insert $ 2 $ between $ 1 $ and $ 3 $ in $ A $, resulting in $ A = (1, 2, 3) $. Thus, when performing these operations, $ S_1 = (1, 3), S_2 = (1, 2, 3) $. Other possible cases are:
- $ S_1 = (1, 1), S_2 = (1, 1, 1) $
- $ S_1 = (1, 1), S_2 = (1, 1, 3) $
- $ S_1 = (1, 3), S_2 = (1, 3, 3) $
- $ S_1 = (1, 3), S_2 = (1, 3, 1) $
These are $ 4 $ additional cases. Therefore, the answer is $ 5 $.
Sample Explanation 2
Output the result modulo $ 998244353 $.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分