P24276 [AtCoder] |LIS| = 3
提高-
题目描述

Problem Statement

Find the number of sequences that satisfy all of the conditions below, modulo 998244353.

  • The length is N.
  • Each of the elements is an integer between 1 and M (inclusive).
  • Its longest increasing subsequence has the length of exactly 3.

Input

Input is given from Standard Input in the following format:
N M

Output

Print the answer.

Constraints

  • $3 \leq N \leq 1000$
  • $3 \leq M \leq 10$
  • All values in input are integers.

Sample Input 1

4 5

Sample Output 1

135

One sequence that satisfies the conditions is (3,4,1,5).
On the other hand, (4,4,1,5) do not, because its longest increasing subsequence has the length of 2.

Sample Input 2

3 4

Sample Output 2

4

Sample Input 3

111 3

Sample Output 3

144980434

Find the count modulo 998244353.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 5
样例输出
135