import sys
sys.setrecursionlimit(10000)


n = int(input());

beats = [input() for i in range(n)]
seen = [False for i in range(n)]
solution = []

def dfs(i):
    seen[i] = True

    for j in range(n):
        if beats[i][j] == '1' and not seen[j]:
            dfs(j)
    
    solution.append(i)

dfs(0)

if len(solution) == n:
    print(" ".join(map(str, solution)))
else:
    print("impossible")

