import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) a = [readline().rstrip().decode().split() for _ in range(n)] ans = -1 for i in range(n): for j in range(n): if i == j: continue if a[j][i] != 'nyanpass': break else: if ans != -1: print(-1) break ans = i + 1 else: print(ans)