#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<vector<string> > mat(N, vector<string>(N));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin >> mat[i][j];
        }
    }
    int ans = -2;
    for(int i = 0; i < N; i++){
        bool flag = true;
        for(int j = 0; j < N; j++){
            if(i==j) continue;
            if(mat[j][i] != "nyanpass") flag = false;
        }
        if(flag){
            if(ans == -2) ans = i+1;
            else ans = -1;
        }
    }
    if(ans == -2) ans = -1;
    cout << ans << endl;
    return 0;
}