from collections import Counter N=int(input()) S=[list(map(int,input().split())) for i in range(N)] ANS=[0]*N def win(x,y): if S[x][y]==1: return x else: return y def calc(X,f): if len(X)==2: a,b=X[0],X[1] DX=Counter() if S[a][b]==1: DX[a]=f else: DX[b]=f return DX DD=Counter() for i in range(1<