import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) A = np.array(read().decode().split()).reshape(N,N) x = (A == 'nyanpass').sum(axis = 0) cand = np.where(x == N - 1)[0] + 1 if len(cand) != 1: print(-1) else: print(cand[0])