#P1811C. Restore the Array
Restore the Array
No submission language available for this problem.
Description
Kristina had an array of length consisting of non-negative integers.
She built a new array of length , such that ().
For example, suppose Kristina had an array = [] of length . Then she did the following:
- Calculated ;
- Calculated ;
- Calculated ;
- Calculated .
You only know the array . Find any matching array that Kristina may have originally had.
The first line of input data contains a single integer () — the number of test cases.
The description of the test cases follows.
The first line of each test case contains one integer () — the number of elements in the array that Kristina originally had.
The second line of each test case contains exactly non-negative integer — elements of array ().
It is guaranteed that the sum of over all test cases does not exceed , and that array was built correctly from some array .
For each test case on a separate line, print exactly non-negative integers — the elements of the array that Kristina originally had.
If there are several possible answers — output any of them.
Input
The first line of input data contains a single integer () — the number of test cases.
The description of the test cases follows.
The first line of each test case contains one integer () — the number of elements in the array that Kristina originally had.
The second line of each test case contains exactly non-negative integer — elements of array ().
It is guaranteed that the sum of over all test cases does not exceed , and that array was built correctly from some array .
Output
For each test case on a separate line, print exactly non-negative integers — the elements of the array that Kristina originally had.
If there are several possible answers — output any of them.
Note
The first test case is explained in the problem statement.
In the second test case, we can get array = [] from the array = []:
- ;
- ;
- .
In the third test case, all elements of the array are zeros. Since each is the maximum of two adjacent elements of array , array can only consist entirely of zeros.
In the fourth test case, we can get array = [] from the array = [] :
- ;
- ;
- ;
- ;
- .