#include "iostream" using namespace std; int main(){ int n,i,j; cin >> n; string greet[n][n]; for (i = 0; i < n; i++){ for (j = 0; j < n; j++) cin >> greet[i][j]; } int cnt,ans; cnt = 0; ans = -1; for (j = 0; j < n; j++){ for (i = 0; i < n; i++){ if (i != j && greet[i][j] != "nyanpass") break; } if (i == n){ cnt++; ans = j+1; } if (cnt > 1){ ans = -1; break; } } cout << ans << endl; return 0; }