#P1618A. Polycarp and Sums of Subsequences
Polycarp and Sums of Subsequences
No submission language available for this problem.
Description
Polycarp had an array of positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array of integers.
For example, if , then Polycarp wrote out , , , , , , . After sorting, he got an array
Unfortunately, Polycarp lost the array . He only has the array left. Help him to restore the array .
The first line contains one integer () — the number of test cases.
Each test case consists of one line which contains integers (; ).
Additional constraint on the input: there exists at least one array which yields this array as described in the statement.
For each test case, print integers — , and . If there can be several answers, print any of them.
Input
The first line contains one integer () — the number of test cases.
Each test case consists of one line which contains integers (; ).
Additional constraint on the input: there exists at least one array which yields this array as described in the statement.
Output
For each test case, print integers — , and . If there can be several answers, print any of them.
Samples
Note
The subsequence of the array is a sequence that can be obtained from by removing zero or more of its elements.
Two subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length has exactly different non-empty subsequences.