#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <stdio.h>
#include <stdint.h>
using namespace std;

using uint = unsigned int;
using ll = long long;

#define CIN( LL , A ) LL A; cin >> A 
#define GETLINE( A ) string A; getline( cin , A ) 

int main()
{

  CIN( ll , N );
  string a;
  vector<list<string> > A( N + 1 , list<string>() );

  for( ll i = 1 ; i <= N ; i++ ){

    for( ll j = 1 ; j <= N ; j++ ){
    
      cin >> a;
      A[j].push_back( a );

    }
    
  }

  const string h = "-";
  const string n = "nyanpass";

  ll answer = 0;
  
  for( ll j = 1 ; j <= N && answer != -1 ; j++ ){

    const list<string>& Aj = A[j];
    bool poi = true;
    
    for( auto itr = Aj.begin() , end = Aj.end() ; itr != end && poi ; itr++ ){

      const string& Aij = *itr;
      
      if( Aij != h && Aij != n ){

	poi = false;

      }

    }

    if( poi ){

      if( answer == 0 ){

	answer = j;

      } else {

	answer = -1;

      }

    }

  }

  if( answer == 0 ){

    answer = -1;

  }

  cout << answer << endl;
  return 0;

}