#P6429. Problem D. Permutation

Problem D. Permutation

Problem Description

Define the value of a permutation of 1 . . . n as
n
∑|pi - i|
i=1

Given n, p, for every s = 0 . . . n^2-1, count the number of permutations of length n
whose value equals to s.
Output the answer modulo a prime p.

Input

The first line of the input contains an integer T , denoting the number of test cases.
In each test case, there are two integers n, p in one line, denoting the length of permutations and the modulo.
1 ≤ T ≤ 10, 1 ≤ n ≤ 100, 10^9 < p < 1.1 × 10^9, only two cases’ n > 50, p is a prime.

Output

For each test case, output one line contains n^2 integer, denoting the number of permutations of length n whose value equals to s = 0 . . . n^2-1 modulo p.

4 4 1000000223 3 1000000321 2 1000000123 1 1000000447
1 0 3 0 7 0 9 0 4 0 0 0 0 0 0 0 1 0 2 0 3 0 0 0 0 1 0 1 0 1