Problem8969--[yosupo] Enumerative Combinatorics - Montmort Number

8969: [yosupo] Enumerative Combinatorics - Montmort Number

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB  Special Judge

Description

Let $a_k$ be the number of size $k$ permutations $p$ s.t. $p_i \neq i$ for each $i$.
Given $N, M$. For each $i = 1, \cdots, N$, print $b_k = a_k \bmod M$.

Input

$N$ $M$

Output

$b_1$ $b_2$ $\ldots$ $b_N$
注意第一个数据前面有一个空格。

Constraints

$1 \leq N \leq 10^6$
$1 \leq M \leq 10^9$

Sample 1 Input

10 100

Sample 1 Output

 0 1 2 9 44 65 54 33 96 61

Sample 2 Input

20 998244353

Sample 2 Output

 0 1 2 9 44 265 1854 14833 133496 1334961 14684570 176214841 294304226 127281753 910981941 600290115 222488424 11814221 224470198 496426549

HINT

相同题目:Yosupo

Source/Category