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

class Program
{
    public void Solve()
    {
        const string nyanpass = "nyanpass";

        int N = int.Parse(Console.ReadLine());
        int[] arr = new int[N];
        string[] A;

        for (int i = 0; i < N; i++)
        {
            A = Console.ReadLine().Split(' ');
            for (int j = 0; j < N; j++)
            {
                if (A[j] == nyanpass) { arr[j]++; }
            }
        }
        int renCnt = arr.Where(x => x == N - 1).Count();
        Console.WriteLine(renCnt == 1 ? Array.IndexOf(arr, N - 1) + 1 : -1);
    }

    static void Main()
    {
        var solver = new Program();
        solver.Solve();
    }
}