#P12415. 「YLLOI-R1-T4」枫
「YLLOI-R1-T4」枫
Description
There is a grid with rows and columns. You need to construct a tree on this grid such that:
- Each node of the tree corresponds to a cell in the grid.
- Each cell can correspond to at most one node.
- For any node in the tree, the row of its corresponding cell is strictly less than the row of any of its children. (Rows are numbered from top to bottom.)
The nodes are unlabelled; all nodes are identical.
Two trees are considered identical if they satisfy all the following conditions:
- They contain the same number of nodes.
- The set of grid cells corresponding to the nodes are the same. Formally, if the set of cells used in the two trees are and , then .
- The parent–child relationships are exactly the same. Formally, for every cell , let and be the sets of cells corresponding to the children of in the two trees,then .
Determine how many distinct trees can be constructed. Output the answer modulo .
Input Format
A single line containing two positive integers and .
Output Format
A single integer — the number of distinct trees modulo .
2 2
10
3 2
86
Hint
Explanation
Sample 1:
The figure below shows all distinct trees:

Sample 2:
- There are distinct trees with node.
- There are distinct trees with nodes.
- There are distinct trees with nodes.
- There are distinct trees with nodes.
- There are distinct trees with nodes.
- There are distinct trees with nodes.
So in total, there are distinct trees.
Constraints
This problem uses subtask scoring.
- Subtask 1 (10 pts): .
- Subtask 2 (10 pts): .
- Subtask 3 (10 pts): .
- Subtask 4 (20 pts): .
- Subtask 5 (20 pts): .
- Subtask 6 (30 pts): No additional constraints.
For all data: .
京公网安备 11011102002149号