N = int(input()) A = [] for i in range(N): A.append(list(input().split())) ans = [] for j in range(N): for i in range(N): if i == j: continue if A[i][j] != "nyanpass": break else: ans.append(j + 1) if len(ans) != 1: print(-1) else: print(ans[0])