#2662. 完成序列
完成序列
Problem Description
You probably know those quizzes in Sunday magazines: given the sequence , what is the next number? Sometimes it is very easy to answer, sometimes it could be pretty hard. Because these "sequence problems" are very popular, ACM wants to implement them into the "Free Time" section of their new WAP portal.
ACM programmers have noticed that some of the quizzes can be solved by describing the sequence by polynomials. For example, the sequence can be easily understood as a trivial polynomial. The next number is 6. But even more complex sequences, like , can be described by a polynomial. In this case, can be used. Note that even if the members of the sequence are integers, polynomial coefficients may be any real numbers.
Polynomial is an expression in the following form:
$P(n) = a_D\cdot n^D+a_{D-1}\cdot n^{D-1}+...+a_1\cdot n+a_0$. If , the number is called a degree of the polynomial. Note that constant function can be considered as polynomial of degree , and the zero function is usually defined to have degree .
Format
Input
There is a single positive integer on the first line of input. It stands for the number of test cases to follow. Each test case consists of two lines. First line of each test case contains two integer numbers and separated by a single space, . The first number, , stands for the length of the given sequence, the second number, is the amount of numbers you are to find to complete the sequence.
The second line of each test case contains S integer numbers separated by a space. These numbers form the given sequence. The sequence can always be described by a polynomial such that for every , . Among these polynomials, we can find the polynomial with the lowest possible degree. This polynomial should be used for completing the sequence.
Output
For every test case, your program must print a single line containing integer numbers, separated by a space. These numbers are the values completing the sequence according to the polynomial of the lowest possible degree. In other words, you are to print values .
It is guaranteed that the results will be non-negative and will fit into the standard integer type.
Sample
4
6 3
1 2 3 4 5 6
8 2
1 2 4 7 11 16 22 29
10 2
1 1 1 1 1 1 1 1 1 2
1 10
3
7 8 9
37 46
11 56
3 3 3 3 3 3 3 3 3 3