N = int(raw_input()) notrenchon = [] for i in xrange(N): A = raw_input().split() for j in xrange(N): if A[j] not in ('nyanpass', '-'): notrenchon.append(j + 1) candset = set([i for i in xrange(1, N+1)]) - set(notrenchon) if len(candset) == 1: print candset.pop() else: print -1