403220: GYM101081 C Salt Mine
Description
Wieliczka city in Poland is known for its imposing salt mine. The extraction of salt must obey important restrictions, since the walls and ceiling must stay stable as the good is being extracted. Engineering studies show that the production of salt of a mine can be modeled by a polinomial A(x) (where x is the total volume extracted from the mine). It is know that after a day of work, when x0 material was extracted from the mine, the production now becomes q(x) and there is a waste of r where A(x) = q(x)(x - x0) + r.
Your task id, given A(x) and an integer x0, determine the waste r and the new polynomial related to the new production capacity q(x).
InputThe first line has an integer T, the number of test cases.
Each test case begins with two integers n and x0, the number of terms in the polynomial and the quantity of extracted salt. The following line has n + 1 integers, the coefficients of A(x). The ith integer on the line is the coefficient of xi - 1.
Limits
- 1 ≤ T ≤ 104
- 1 ≤ n ≤ 15
- 1 ≤ x0 ≤ 50
- Each coefficient is between 0 and 100
For each test, print the waste r and then a line with n integers, the polynomial q(x). The ith integer in that line is the coefficient of xi - 1 in q(x). It is guaranteed all terms in the output will fit in a 64-bit signed integer.
ExampleInput3Output
2 3
3 2 4
3 7
1 10 5 7
1 30
1 0
45
14 4
2717
388 54 7
1
0