using System;

namespace Takmicenje___2022_12_17
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] temp = Console.ReadLine().Trim().Split(' ');
            int a = int.Parse(temp[0]);
            int b = int.Parse(temp[1]);
            temp = Console.ReadLine().Trim().Split(' ');
            int x = int.Parse(temp[0]);
            int y = int.Parse(temp[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("?");
        }
    }
}