A Reasonable Ranking

No attempts yetTime limit1sMemory limit128 MB

Problem

Recently a large StarCraft II league was held: a round-robin tournament with NN players in which every player played against each other player exactly once. The results were recorded in an N×NN \times N table, but it is not obvious from the table which players are stronger. As the organizer, you decide to produce a reasonable ranking of the players.

Let xx and yy be two different players, and suppose xx is ranked higher than yy. The ordered pair (x,y)(x, y) is reasonable if at least one of the following holds:

  1. player xx won the game against player yy; or
  2. there exists another player zz, ranked strictly between xx and yy, such that both (x,z)(x, z) and (z,y)(z, y) are reasonable.

A ranking — an ordering of all players from highest to lowest — is reasonable if every pair (x,y)(x, y) with xx ranked higher than yy is reasonable.

Given the results table, produce a reasonable ranking of the players.

Input

The input consists of several test cases. Each test case begins with a line containing a single integer NN (1N1,0001 \le N \le 1{,}000), the number of players. The next NN lines describe the win-loss table MM: each is a string of length NN consisting only of the characters '0' and '1', with no leading or trailing spaces. The jj-th character of the ii-th line, MijM_{ij}, is 1 if player ii beat player jj and 0 otherwise. For every iji \ne j, exactly one of MijM_{ij} and MjiM_{ji} is 1 (there are no draws), and Mii=0M_{ii} = 0 for all ii. The input ends with a line containing N=0N = 0, which must not be processed.

Output

For each test case, print a reasonable ranking of all the players on one line, from the highest-ranked player to the lowest, separated by single spaces. Since more than one reasonable ranking may exist, print the lexicographically smallest one (compare rankings as sequences of player numbers). If no reasonable ranking exists, print impossible (without quotes) instead.