For an integer , let denote the residue classes modulo . In this problem, every residue is represented by one of .
A nonzero polynomial of degree ,
is called a palindromic polynomial if for every . The zero polynomial is not considered palindromic.
You are given a nonzero polynomial over ,
Construct an integer with and palindromic polynomials such that
All coefficient additions are performed modulo .
Input
The input is given from Standard Input in the following format:
Each case is given in the following format:
Here is the modulus for the coefficients and is the degree of the input polynomial. The coefficients are given from the constant term to the leading term.
Output
For each test case, first print the number of palindromic polynomials used.
Then print lines. For the -th palindromic polynomial
print one line in the following format:
The output must satisfy all of the following conditions.
- .
- for every .
- for every and .
- for every .
- Every is palindromic.
- For every , treating the coefficient of in as when , the coefficient of in is congruent to modulo .
If there are multiple valid outputs, print any of them. Do not print any separator between test cases.
Constraints
- .
- .
- .
- for every .
- .
- Over all test cases, .
Subtasks
Samples
All three printed polynomials are palindromic. Adding their coefficients modulo gives , which is exactly the input polynomial.