AtCoder Grand Contest 055
F
Creative Splitting
AtCoder
⌀ 4288
原题
← E→
翻译中…

Problem Statement

翻译中…

You are given integers $N$ and $K$.

翻译中…

Let's call an integer array $a=[a_1, a_2, \ldots, a_K]$ of length $K$ good, if $1 \le a_i \le i$ for all $1 \le i \le K$.

翻译中…

Let's call an integer array $b=[b_1, b_2, \ldots, b_{NK}]$ of length $NK$ amazing, if it can be split into $N$ (not necessarily contiguous) subsequences of length $K$, each of which is good.

翻译中…

Let's define $f(pos, val)$ as the number of amazing sequences $b$ such that $b_{pos}=val$.

翻译中…

Find $f(pos, val)$ for all $1\le pos \le NK$, $1 \le val \le K$. As these numbers can be very big, output them modulo some prime $P$.

翻译中…

Constraints

翻译中…
  • $1 \le N \le 20$.
  • $1 \le K \le 20$.
  • $10^8 \le P \le 10^9$
  • $P$ is a prime.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N K P

翻译中…

Output

翻译中…

Output $NK$ lines. The $j$-th number in the $i$-th line should be equal to $(f(i, j) \bmod P)$.

翻译中…

样例

Input #1
2 2 965166677
Output #1
6 0
4 2
4 2
3 3
There exist $6$ amazing arrays: - $[1, 1, 1, 1]$ ー can be split into $[b_1, b_2], [b_3, b_4]$. - $[1, 1, 1, 2]$ ー can be split into $[b_1, b_2], [b_3, b_4]$. - $[1, 2, 1, 1]$ ー can be split into $[b_1, b_2], [b_3, b_4]$. - $[1, 2, 1, 2]$ ー can be split into $[b_1, b_2], [b_3, b_4]$. - $[1, 1, 2, 1]$ ー can be split into $[b_1, b_3], [b_2, b_4]$. - $[1, 1, 2, 2]$ ー can be split into $[b_1, b_3], [b_2, b_4]$.
题目信息
题号
agc055_f
时间限制
4 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。