#P6049. 燔祭

燔祭

Problem Description

Compute the number of labeled rooted trees that satisfy the following conditions:

  • The tree has nn nodes in total.
  • Each node has an integer weight in the range [1,m][1,m].
  • The weight of each node is not greater than the weight of its parent.

The answer may be very large. Output the value modulo 998244353998244353.

Two trees T1T_1 and T2T_2 are different if and only if they have different numbers of nodes, or different roots, or there exists a label ii such that the parent label of node ii is different in T1T_1 and T2T_2, or the weight of node ii is different.

Input Format

One line with two positive integers n,mn,m, as described above.

Output Format

One line with one integer, the required answer.

2 2
6
4 6
13524
9 34
857311624

Hint

Sample Explanation

For the first sample,

The six trees are shown in the figure above. The number inside each circle is the node label, and the number outside each circle is the node weight.


Constraints

This problem uses bundled testdata.

For all test cases, it is guaranteed that 1n4001 \leq n \leq 400 and 1m<9982443531 \leq m < 998244353.

Subtask 1 (7 pts)\text{Subtask 1 (7 pts)} n=3,m=3n = 3, m = 3.

Subtask 2 (11 pts)\text{Subtask 2 (11 pts)} m=1m = 1.

Subtask 3 (19 pts)\text{Subtask 3 (19 pts)} n,m6n, m \leq 6.

Subtask 4 (17 pts)\text{Subtask 4 (17 pts)} n7n \leq 7.

Subtask 5 (11 pts)\text{Subtask 5 (11 pts)} n,m50n, m \leq 50.

Subtask 6 (35 pts)\text{Subtask 6 (35 pts)} No special constraints.

Translated by ChatGPT 5