import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		String[][] greetArr = new String[N][N];

		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				greetArr[i][j] = scan.next();
			}
		}

		boolean isFindRenchon = false;
		boolean notNyanpassSay = false;
		int renchonCount = 0;
		int renchonDiscoverPos = -1;

		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(greetArr[j][i].equals("-")){
					//何もしない
				}else if(greetArr[j][i].equals("nyanpass")){
					if(!isFindRenchon){
						renchonDiscoverPos = i;
					}
				}else{
					notNyanpassSay = true;
				}
			}
			if(!notNyanpassSay){
				renchonCount++;
				isFindRenchon = true;
			}
			notNyanpassSay = false;
		}

		if(renchonCount == 1 && isFindRenchon){
			System.out.println(renchonDiscoverPos + 1);
		}else{
			System.out.println(-1);
		}

		scan.close();
	}

}