N=int(input()) a=[[i for i in input().split()] for i in range(N)] R=[0] i=1 while i 0: j=0 while j