// No.239 にゃんぱすー
// https://yukicoder.me/problems/no/239
//
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int solve(vector<vector<string>>& greetings, int N);


int main() {
    int N;
    cin >> N;

    vector<vector<string>> greetings;
    greetings.resize(N);
    for (auto y = 0; y < N; y++) {
        greetings[y].resize(N);
        for (auto x = 0; x < N; x++) {
            cin >> greetings[y][x];
        }
    }

    int ans = solve(greetings, N);
    cout << ans << endl;

}

int solve(vector<vector<string>>& greetings, int N) {
    vector<int> candidates;

    for (auto y = 0; y < N; y++) {
        for (auto x = 0; x < N; x++) {
            if (greetings[y][x] == "nyanpass")
                greetings[x][y] = "nyanpass";
        }
    }

    for (auto y = 0; y < N; y++) {
        int c = 0;
        for (auto j: greetings[y]) {
            if (j == "nyanpass")
                c++;
        }
        if (c == (N - 1))
            candidates.push_back(y+1);
    }
    if (candidates.size() == 1)
        return candidates[0];
    else
        return -1;
}