#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)

int N;
signed main()
{
    cin >> N;
    vector<bool> C(N, true);
    string s;
    REP(i,N) REP(j,N) {
        cin >> s;
        if (i == j) continue;
        if (s != "nyanpass") {
            C[j] = false;
        }
    }
    int renchon = -1;
    int ret = -1;
    REP(i,N) {
        if (!C[i]) continue;
        if (renchon == -1) {
            renchon = i;
            ret = i + 1;
        } else {
            ret = -1;
        }
    }
    cout << ret << endl;
    return 0;
}