#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<vector<string>> A(N, vector<string>(N));
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      cin >> A[i][j];
    }
  }
  vector<int> ans;
  for (int i = 0; i < N; i++){
    bool ok = true;
    for (int j = 0; j < N; j++){
      if (j != i){
        if (A[j][i] != "nyanpass"){
          ok = false;
        }
      }
    }
    if (ok){
      ans.push_back(i);
    }
  }
  if (ans.size() == 1){
    cout << ans[0] + 1 << endl;
  } else {
    cout << -1 << endl;
  }
}