#include <iostream>
#include <vector>
using namespace std;

string A[100][100];
int main(){
	int N;
	cin >> N;

	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cin >> A[i][j];
		}
	}

	vector<int> res;
	for(int x=0;x<N;x++){
		bool ok = true;
		for(int i=0;i<N;i++)if(i != x){
			if(A[i][x] != "nyanpass"){
				ok = false;
				break;
			}
		}
		if(ok){
			res.push_back(x + 1);
		}
	}

	cout << (res.size() == 1 ? res[0] : -1) << endl;
	return 0;
}