N = int(input()) A = [] B = [] for i in range(N) : L = list(map(str,input().split())) for j in range(N) : if L[j] == "nyanpass" : A.append(j+1) if len(A) == 0 : print(-1) else : for k in range(N) : a = A.count(k) if a == N-1 : B.append(k) if len(B) >= 2 : print(-1) else : print(B[0])