using System; using System.Collections.Generic; using System.Linq; namespace YukiCoderNo239 { class Program { static void Main() { int length = LIB.IO.R(); int output = -1; string[][] greeding = LIB.IO.R(length, ' '); int okcount = 0; for (int i = 0; i < length; i++) { bool flag = true; for (int j = 0; j < length; j++) { if (!((greeding[i][j] == "nyanpass") || (i == j))) { flag = false; break; } } if (flag == true) { output = i + 1; if (okcount >= 1) { LIB.IO.W(-1); LIB.IO.WFLUSH(); return; } okcount++; } } for (int i = 0; i < length; i++) { bool flag = true; for (int j = 0; j < length; j++) { if (!((greeding[j][i] == "nyanpass") || (i == j))) { flag = false; break; } } if (flag == true) { if (okcount >= 1) { if (output != i + 1) { LIB.IO.W(-1); LIB.IO.WFLUSH(); return; } } output = i + 1; okcount++; } } LIB.IO.W(output); LIB.IO.WFLUSH(); } } } namespace LIB { public class IO { private const int WMAX = 1000; private static string WSTRING = ""; public static T R() { return (T)(Convert.ChangeType(R(), typeof(T))); } public static T[] R(char splitter = ' ') { return R().Split(splitter).Select(v => UTILITY.PARSE(v)).ToArray(); } public static T[] R(int length) { T[] ret = new T[length]; for (int i = 0; i < length; i++) { ret[i] = R(); } return ret; } public static T[][] R(int length, char splitter = ' ') { T[][] ret = new T[length][]; for (int i = 0; i < length; i++) { ret[i] = R(splitter); } return ret; } private static string R() { return Console.ReadLine(); } public static void W(object value, bool addLineFeed = true) { WSTRING += UTILITY.PARSE(value); if (addLineFeed == true) { WSTRING += "\n"; } if (WSTRING.Count() >= WMAX) { WFLUSH(); } } public static void WFLUSH() { Console.Write(WSTRING); WSTRING = ""; } } public class UTILITY { public static T PARSE(object value) { return (T)(Convert.ChangeType(value, typeof(T))); } } }