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

int main() {
    int n;
    string s[110][110];
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> s[i][j];
        }
    }
    
    int ans = 0;
    for (int j = 0; j < n; j++) {
        bool ok = true;
        for (int i = 0; i < n; i++) if (i != j) {
            ok &= (s[i][j] == "nyanpass");
        }
        if (ok) {
            if (ans) ans = -1;
            else ans = j + 1;
        }
    }
    
    if (ans == 0) ans = -1;
    
    cout << ans << '\n';
    return 0;
}