#P15476. [CERC2012] Kingdoms

[CERC2012] Kingdoms

Description

Several kingdoms got into serious financial troubles. For many years, they have been secretly borrowing more and more money from each other. Now, with their liabilities exposed, the crash is inevitable...

There are nn kingdoms. For each pair (A,B)(A,B) of kingdoms, the amount of gold that kingdom A\operatorname{A} owes to kingdom B\operatorname{B} is expressed by an integer number dABd_{AB} (we assume that dBA=dABd_{BA}=−d_{AB}). If a kingdom has negative balance (has to pay more than it can receive), it may bankrupt. Bankruptcy removes all liabilities, both positive and negative, as if the kingdom ceased to exist. The next kingdom may then bankrupt, and so on, until all remaining kingdoms are financially stable.

Depending on who falls first, different scenarios may occur—in particular, sometimes only one kingdom might remain. Determine, for every kingdom, whether it can become the only survivor.

Input Format

The first line of the input contains the number of test cases TT. The descriptions of the test cases follow:

The description of each test case starts with a line containing the number of the kingdoms nn, 1n201\le n\le 20. Then nn lines follow, each containing nn space-separated numbers. The jj-th number in the ii-th line is the number dijd_{ij} of gold coins that the ii-th kingdom owes to the jj-th one. You may assume that dii=0d_{ii}=0 and dij=djid_{ij}=−d_{ji} for every 1i,jn1\le i,j\le n. Also, dij106|d_{ij}|\le 10^6 for all possible i,ji,j.

Output Format

Print the answers to the test cases in the order in which they appear in the input. For each test case, print a single line containing the indices of the kingdoms that can become the sole survivors, in increasing order. If there are no such kingdoms, print a single number 00.

1
3
0 -3 1
3 0 -2
-1 2 0
1 3