import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String str = "nyanpass"; String[][] s = new String[n][n]; boolean[] b = new boolean[n]; for(int i = 0; i < n; i++){ b[i] = true; } for(int i= 0; i < n; i++){ for(int j = 0; j < n; j++){ s[i][j] = sc.next(); } } for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(i == j){ continue; } if(b[j]){ if(!s[i][j].equals(str)){ b[j] = false; } } } } int ren = -1, cnt = n; for(int i = 0; i < n; i++){ if(b[i]){ ren = i; } else { cnt--; } } if(cnt > 1 || cnt == 0){ System.out.println(-1); } else { System.out.println(ren); } } }