import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int ansN = 0; int ans = 0; String[][] a = new String[N][N]; for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { a[i][j] = sc.next(); } } for(int j = 0; j < N; j++) { boolean flg = true; for(int i = 0; i < N; i++) { if((i != j) && (!(a[i][j].equals("nyanpass")))) flg = false; } if(flg) { ansN++; ans = j + 1; } } if(ansN == 0 || ansN > 1) ans = -1; System.out.println(ans); } }