a,b,c,d,e,f=(input()+" "+input()).split();b,e=int(b),int(e);print([d,-1,a][(b>=e)+(b>e)])