atcoder#AGC055F. [AGC055F] Creative Splitting

[AGC055F] Creative Splitting

Score : 18001800 points

Problem Statement

You are given integers NN and KK.

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

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

Let's define f(pos,val)f(pos, val) as the number of amazing sequences bb such that bpos=valb_{pos}=val.

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

Constraints

  • 1N201 \le N \le 20.
  • 1K201 \le K \le 20.
  • 108P10910^8 \le P \le 10^9
  • PP is a prime.

Input

Input is given from Standard Input in the following format:

NN KK PP

Output

Output NKNK lines. The jj-th number in the ii-th line should be equal to (f(i,j)modP)(f(i, j) \bmod P).

2 2 965166677
6 0 
4 2 
4 2 
3 3

There exist 66 amazing arrays:

  • [1,1,1,1][1, 1, 1, 1] ー can be split into [b1,b2],[b3,b4][b_1, b_2], [b_3, b_4].
  • [1,1,1,2][1, 1, 1, 2] ー can be split into [b1,b2],[b3,b4][b_1, b_2], [b_3, b_4].
  • [1,2,1,1][1, 2, 1, 1] ー can be split into [b1,b2],[b3,b4][b_1, b_2], [b_3, b_4].
  • [1,2,1,2][1, 2, 1, 2] ー can be split into [b1,b2],[b3,b4][b_1, b_2], [b_3, b_4].
  • [1,1,2,1][1, 1, 2, 1] ー can be split into [b1,b3],[b2,b4][b_1, b_3], [b_2, b_4].
  • [1,1,2,2][1, 1, 2, 2] ー can be split into [b1,b3],[b2,b4][b_1, b_3], [b_2, b_4].