#include <iostream>

using namespace std;

int main() {

	int n;
	cin >> n;

	string a[n][n];
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}

	int ans = -1;
	int renchon = 0;
	for(int j = 0; j < n; j++) {
		bool isRenchon = true;
		for(int i = 0; i < n; i++ ) {
			if(i == j) continue;
			if(a[i][j] != "nyanpass") {
				isRenchon = false;
			}
		}
		if(isRenchon) {
			renchon++;
			ans = j + 1;
		}
	}

	if(renchon != 1) ans = -1;
	cout << ans << endl;

	return 0;
}