SP196 MUSKET - Musketeers
Description
In the time of Louis XIII and his powerful minister cardinal Richelieu in the Full Barrel Inn _n_ musketeers had consumed their meal and were drinking wine. Wine had not run short and therefore the musketeers were eager to quarrel, a drunken brawl broke out, in which each musketeer insulted all the others.
A duel was inevitable. But who should fight who and in what order? They decided (for the first time since the brawl they had done something together) that they would stay in a circle and draw lots in order. A drawn musketeer fought against his neighbor to the right. A looser "quit the game" and to be more precise his corpse was taken away by servants. The next musketeer who stood beside the looser became the neighbor of a winner.
After years, when historians read memories of the winner they realized that a final result depended in a crucial extent on the order of duels. They noticed that a fence practice had indicated, who against who could win a duel. It appeared that (in mathematical language) the relation "**A** wins **B**" was not transitive! It could happen that the musketeer **A** fought better than **B**, **B** better than **C** and **C** better than **A**. Of course, among three of them the first duel influenced the final result. If **A** and **B** fight as the first, **C** wins eventually. But if **B** and **C** fight as the first, **A** wins finally. Historians fascinated by their discovery decided to verify which musketeers could survive. The fate of France and the whole civilized Europe indeed depended on that!
### Task
_N_ persons with consecutive numbers from _1_ to _n_ stay in a circle. They fight _n-1_ duels. In the first round one of these persons (e.g. with the number _i_) fights against its neighbor to the right, i.e. against the person numbered _i+1_ (or, if _i=n_, against the person numbered _1_). A looser quits the game, and the circle is tighten so that the next person in order becomes a winner's neighbor. We are given the table with possible duels results, in the form of a matrix. If **A**_i,j_ = 1 then the person with the number _i_ always wins with the person _j_. If **A**_i,j_ = 0 the person _i_ looses with _j_. We can say that the person _k_ may win the game if there exists such a series of _n-1_ drawings, that _k_ wins the final duel.
Write a program which:
- reads matrix **A** from the standard input,
- computes numbers of persons, who may win the game,
- writes them into the standard output.
Input Format
The number of test cases t is in the first line of input, then t test cases follow separated by an empty line. In the first line of each test case integer _n_ which satisfies the inequality _3
Output Format
For each test case in the first line there should be written _m_ - the number of persons, who may win the game. In the following _m_ lines numbers of these persons should be written in ascending order, one number in each line.