P5853 [USACO19DEC] Tree Depth P
Description
For the new year, Farmer John decided to give his cows a festive binary search tree
(BST)!
To generate the BST, FJ starts with a permutation $a=\{a_1,a_2,\ldots,a_N\}$
of the integers $1\ldots N$, where $N\le 300$. He then runs the following
pseudocode with arguments $1$ and $N.$
```
generate(l,r):
if l > r, return empty subtree;
x = argmin_{l
Input Format
The only line of input consists of three space-separated integers $N,K$,and $M$, followed by a new line. $M$ will be a prime number in the range $[10^8,10^9+9]$.
Output Format
Print $N$ space-separated integers denoting $\sum_a d_i(a) (\bmod M)$ for each $1\leq i\leq N$
Explanation/Hint
### Sample Explanation
For the first example,the only permutation is $a=\{1,2,3\}$.
For the second example,the two permutations are $a=\{1,3,2\}$ and $a=\{2,1,3\}$.
### Data range
Test cases $3-4$ satisfy $N\leq 8$.
Test cases $5-7$ satisfy $N\leq 20$.
Test cases $8-10$ satisfy $N\leq 50$.