#include <iostream>
using namespace std;
int main()
{
    unsigned char a,b,x,y;
    cin>>a>>b>>x>>y;
    if(a==x)
    {
        if(y<b)
            cout<<"drugi";
        else cout<<"nijedan";
    }
    else{
        if(b==y){
            if(x<a)
                cout<<"prvi";
            else cout<<"nijedan";
        }
      else cout<<"?";}
    return 0;
}