Score : 1800 points
Problem Statement
You are given integers N and K.
Let's call an integer array a=[a1,a2,…,aK] of length K good, if 1≤ai≤i for all 1≤i≤K.
Let's call an integer array b=[b1,b2,…,bNK] 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 bpos=val.
Find f(pos,val) for all 1≤pos≤NK, 1≤val≤K.
As these numbers can be very big, output them modulo some prime P.
Constraints
- 1≤N≤20.
- 1≤K≤20.
- 108≤P≤109
- P is a prime.
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)modP).
2 2 965166677
6 0
4 2
4 2
3 3
There exist 6 amazing arrays:
- [1,1,1,1] ー can be split into [b1,b2],[b3,b4].
- [1,1,1,2] ー can be split into [b1,b2],[b3,b4].
- [1,2,1,1] ー can be split into [b1,b2],[b3,b4].
- [1,2,1,2] ー can be split into [b1,b2],[b3,b4].
- [1,1,2,1] ー can be split into [b1,b3],[b2,b4].
- [1,1,2,2] ー can be split into [b1,b3],[b2,b4].