#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n;
	string str;

	cin >> n;
	vector<bool> isRen(n, true);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> str;

			if (str == "-") {
				continue;
			} else if (str != "nyanpass") {
				isRen[j] = false;
			}
		}
	}

	int cnt = 0;
	int idx = -1;
	for (int i = 0; i < n; i++) {
		if (isRen[i]) {
			idx = i + 1;
			cnt++;
		}
	}

	cout << (cnt == 1 ? idx : -1) << endl;
	return 0;
}