la=input().split() lb=input().split() if int(la[1])==int(lb[1]): print(-1) elif int(la[1])>int(lb[1]): print(la[0]) elif int(la[1])