#coding: UTF-8 import sys import re import itertools from collections import deque ### defs ### ### main ### N = int(sys.stdin.readline()) A = [] for n in range(N): A.append(sys.stdin.readline().split()) for i in range(N): for j in range(i+1,N): A[i][j], A[j][i] = A[j][i], A[i][j] ans=-1 cnt=0 for n in range(N): if(A[n].count("nyanpass")==N-1): cnt+=1 ans=n+1 if(cnt!=1): ans=-1 print(ans)