def ILLINRows(N): return [input().split() for i in range(N)] def transpose(matrix): if matrix ==[]: return [] if matrix[0] ==1: return list(map(list, zip(matrix))) else: return list(map(list, zip(*matrix))) n = int(input()) twoArray=ILLINRows(n) twoArray=transpose(twoArray) for i in enumerate(twoArray): if i[1].count("nyanpass")==n-1: print(i[0]+1) exit() print(-1)