#agc055f. [agc055_f]Creative Splitting
[agc055_f]Creative Splitting
Problem Statement
You are given integers and .
Let's call an integer array a=\[a_1, a_2, \\ldots, a_K\] of length good, if for all .
Let's call an integer array b=\[b_1, b_2, \\ldots, b_{NK}\] of length amazing, if it can be split into (not necessarily contiguous) subsequences of length , each of which is good.
Let's define as the number of amazing sequences such that .
Find for all , . As these numbers can be very big, output them modulo some prime .
Constraints
- .
- .
- is a prime.
Input
Input is given from Standard Input in the following format:
Output
Output lines. The -th number in the -th line should be equal to .
Sample Input 1
2 2 965166677
Sample Output 1
6 0
4 2
4 2
3 3
There exist 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\].