using System
{
    namespace takm1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split();
            int a = Convert.ToInt32(s1[0]);
            int b = Convert.ToInt32(s1[1]);

            s1 = Console.ReadLine().Split();
            int x = Convert.ToInt32(s1[0]);
            int y = Convert.ToInt32(s1[1]);

            if ((a == x) && (b == y)) Console.WriteLine("nijedan");
            else if (a == x) Console.WriteLine("drugi");
            else if (b == y) Console.WriteLine("prvi");
            else  Console.WriteLine("?");
        }
    }
}
}