Under construction

Still being built. Things may change

Tree

Time limit3sMemory limit1024 MB

Summary
For each n up to N, count pairs of the two specified rooted trees whose leaf sets are complementary, modulo M.
Level

Hard9 of 10

Topics
Combinatorics, Dynamic programming, Math
Solved
No attempts yet

Problem

We generate two rooted trees with nn vertices as follows.

The first tree is generated as follows:

  1. Vertex 11 is the root of the tree.
  2. For every i∈[2,n]i \in [2,n], choose one vertex from [1,i−1][1,i-1] as the parent of ii.

The second tree is generated as follows:

  1. Vertex nn is the root of the tree.
  2. For every i∈[1,n−1]i \in [1,n-1], choose one vertex from [i+1,n][i+1,n] as the parent of ii.

A way of generating the trees is good if and only if every vertex ii that is a leaf in tree 1 is not a leaf in tree 2, and every vertex ii that is not a leaf in tree 1 is a leaf in tree 2. The root of each tree is not a leaf, regardless of the number of adjacent edges.

For every n∈[2,N]n \in [2,N], calculate the number of good ways to generate the trees. Two ways are different if and only if there is a vertex ii such that the parent of ii is different in at least one of the two trees. Output the answer modulo MM.

Input

The first line of input contains two integers NN and MM (2≤N≤5002 \le N \le 500, 10≤M≤23010 \le M \le 2^{30}).

Output

Output N−1N-1 lines: the answers for n=2,3,…,Nn=2,3,\ldots,N.

Examples1

  1. Example 1

    Input
    5 998244353
    
    Expected output
    1
    2
    12
    120