atcoder#ABC248F. [ABC248F] Keep Connect

[ABC248F] Keep Connect

Score : 500500 points

Problem Statement

You are given an integer NN greater than or equal to 22 and a prime PP. Consider the graph GG with 2N2N vertices and (3N2)(3N-2) edges shown in the figure below.

More specifically, the edges connect the vertices as follows, where the vertices are labeled as Vertex 11, Vertex 22, \ldots, Vertex 2N2N, and the edges are labeled as Edge 11, Edge 22, \ldots, Edge (3N2)(3N-2).

  • For each 1iN11\leq i\leq N-1, Edge ii connects Vertex ii and Vertex i+1i+1.
  • For each 1iN11\leq i\leq N-1, Edge (N1+i)(N-1+i) connects Vertex N+iN+i and Vertex N+i+1N+i+1.
  • For each 1iN1\leq i\leq N, Edge (2N2+i)(2N-2+i) connects Vertex ii and Vertex N+iN+i.

For each i=1,2,,N1i=1,2,\ldots ,N-1, solve the following problem.

Find the number of ways, modulo PP, to remove exactly ii of the 3N23N-2 edges of GG so that the resulting graph is still connected.

Constraints

  • 2N30002 \leq N \leq 3000
  • 9×108P1099\times 10^8 \leq P \leq 10^9
  • NN is an integer.
  • PP is a prime.

Input

Input is given from Standard Input in the following format:

NN PP

Output

Print N1N-1 integers, the ii-th of which is the answer for i=ki=k, separated by spaces.

3 998244353
7 15

In the case N=3N=3, there are 77 ways, shown below, to remove exactly one edge so that the resulting graph is still connected.

There are 1515 ways, shown below, to remove exactly two edges so that the resulting graph is still connected.

Thus, these numbers modulo P=998244353P=998244353 should be printed: 77 and 1515, in this order.

16 999999937
46 1016 14288 143044 1079816 6349672 29622112 110569766 330377828 784245480 453609503 38603306 44981526 314279703 408855776

Be sure to print the numbers modulo PP.