using System;
using System.Collections.Generic;
using System.Linq;

public static class Program
{
    const string NYANPASS = "nyanpass";
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        var matrix = new string[N, N];

        // 行列生成
        string[] line;
        for (int i=0; i<N; i++)
        {
            line = Console.ReadLine().Split(' ');
            for (int j=0; j<N; j++)
            {
                matrix[i,j] = line[j]; 
            }
        }

        // 検知
        var set = new HashSet<int>();
        int counter = 0;

        for (int i = 0; i < N; i++)
        {
            counter = 0;
            for (int j = 0; j < N; j++)
            {
                if (matrix[j, i] == NYANPASS) counter++;
            }
            if (counter == N - 1) set.Add(i);
        }

        Console.WriteLine( (set.Count() == 1 ) ? set.First() + 1 : -1);
    }
} // class Program