This page is still under construction.

Parts of this page are still being built. What you see may change.

Tribute

Time limit15sMemory limit512 MB

Summary
Given all 2^n - 1 non-empty subset sums, recover the n positive values they came from, or report that the answer is missing or not unique.
Level

Medium7 of 10

Topics
Sorting, Greedy, Implementation, Math
Solved
No attempts yet

Problem

The Son of Heaven, our beloved emperor, has commanded you, his First Minister, to extort tribute from nn neighbouring kingdoms. Each tributary has been assigned a number of silver coins to pay: for the ii-th kingdom, the number is aia_i. To show His infinite grace, the emperor decided to take money from only some of the countries and spare the rest. Your overzealous finance minister, after writing down all aia_i, has already produced all possible 2n−12^n - 1 income values, the sums of the non-empty subsets of tributaries. Unfortunately, in the process the minister lost the paper sheet with the original tribute values. For this infraction, as well as improper calligraphy, he was promptly executed.

Now you have only 2n−12^n - 1 sums, written rather badly. Can you recover the tribute values from them?

Input

The first line of input contains the number of test cases zz (1≤z≤200)(1 \leq z \leq 200). The descriptions of the test cases follow.

Every test case consists of two lines: the first contains a number nn (1≤n≤20)(1 \le n \le 20), the second contains 2n−12^n -1 integers not exceeding 2⋅1092 \cdot 10^9, denoting all the possible sums of tributes. Assume that the tribute values were all positive integers. The total number of sums in all test cases does not exceed 10710^7.

Output

For each test case output the recovered values of aia_i for i=1,2,…,ni = 1, 2, \ldots, n, in increasing order. If there are no values that fit the input, or if there are multiple possibilities, simply write ``\texttt{NO}'' instead: you cannot execute anyone twice.

Examples1

  1. Example 1

    Input
    1
    3
    1 2 3 3 4 5 6
    
    Expected output
    1 2 3