#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

int main() {

  int N; cin >> N;
  vector<vector<string>> A(N, vector<string>(N));
  rep(i, N) {
    rep(j, N) {
      cin >> A[i][j];
    }
  }

  int ans = 0;

  rep(j, N) {
    bool ok = true;
    rep(i, N) {
      if(i == j) { continue; }
      if(A[i][j] != "nyanpass") { ok = false; break; }
    }
    if(ok) {
      if(ans == 0) {
        ans = j+1;
      }
      else {
        ans = -1;
      }
    }
  }

  if(ans <= 0) {
    cout << -1 << endl;
  }
  else {
    cout << ans << endl;
  }

  return 0;
}