#P6049. 燔祭
燔祭
Problem Description
Compute the number of labeled rooted trees that satisfy the following conditions:
- The tree has nodes in total.
- Each node has an integer weight in the range .
- The weight of each node is not greater than the weight of its parent.
The answer may be very large. Output the value modulo .
Two trees and are different if and only if they have different numbers of nodes, or different roots, or there exists a label such that the parent label of node is different in and , or the weight of node is different.
Input Format
One line with two positive integers , 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 and .
.
.
.
.
.
No special constraints.
Translated by ChatGPT 5