using System;

namespace SPOJLER
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int a = int.Parse(s[0]), b = int.Parse(s[1]);
            s = Console.ReadLine().Split();
            int x = int.Parse(s[0]), y = int.Parse(s[1]);
            if (a == x && b == y)
                Console.WriteLine("nijedan");
            else if (b == y)
                Console.WriteLine("prvi");
            else if (a == x)
                Console.WriteLine("drugi");
            else Console.WriteLine("?");
        }
    }
}