using System;
using System.Text.RegularExpressions;

namespace Takmicenje
{
    internal class Program
    {
        static void Main(string[] args)
        {

            string s = Console.ReadLine();
            if (s.Contains("-"))
            {
                Console.WriteLine("Greska");
                return;
            }
            string[] r1 = Regex.Split(s, @"\D");
            s = Console.ReadLine();
            if (s.Contains("-"))
            {
                Console.WriteLine("Greska");
                return;
            }
            string[] r2 = Regex.Split(s, @"\D");
            if ((int.Parse(r1[0]) <= int.Parse(r2[0]) || int.Parse(r1[1]) <= int.Parse(r2[1])) && (int.Parse(r2[0]) <= 100 && int.Parse(r2[1]) <= 100))
            {
                if (r1[0] == r2[0] && r1[1] != r2[1])
                {
                    Console.WriteLine("drugi");
                    return;
                }
                if (r1[1] == r2[1] && r1[0] != r2[0])
                {
                    Console.WriteLine("prvi");
                    return;
                }
                if (r1[0] == r2[0] && r1[1] == r2[1])
                {
                    Console.WriteLine("nijedan");
                    return;
                }
                else
                {
                    Console.WriteLine("?");
                    return;
                }
            }
            else
            {
                Console.WriteLine("Greksa");
            }
        }
    }
}