#abc248f. F - Keep Connect

F - Keep Connect

Score : 500500 points

问题描述

给定一个大于等于2的整数 NN 和一个质数 PP
考虑下图所示具有2N个顶点和(3N-2)条边的图 GG

更具体地说,边连接顶点的方式如下,其中顶点标记为Vertex 11, Vertex 22, \ldots, Vertex 2N2N,边标记为Edge 11, Edge 22, \ldots, Edge (3N2)(3N-2)

  • 对于每个 1iN11\leq i\leq N-1,Edge ii 连接Vertex ii 和 Vertex i+1i+1
  • 对于每个 1iN11\leq i\leq N-1,Edge (N1+i)(N-1+i) 连接Vertex N+iN+i 和 Vertex N+i+1N+i+1
  • 对于每个 1iN1\leq i\leq N,Edge (2N2+i)(2N-2+i) 连接Vertex ii 和 Vertex N+iN+i

对于 i=1,2,,N1i=1,2,\ldots ,N-1,解决以下问题。

求在模 PP 下,从 GG3N23N-2 条边中恰好移除 ii 条边,使得得到的图仍然保持连通的方法数量。

以上为通义千问 qwen-max 翻译,仅供参考。

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.

Sample Input 1

3 998244353

Sample Output 1

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.

Sample Input 2

16 999999937

Sample Output 2

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

Be sure to print the numbers modulo PP.

update @ 2024/3/10 10:37:43