Sa,Pa,Xa = input().split() Sb,Pb,Xb = input().split() if Pa == Pb: print(-1) elif int(Pa) > int(Pb): print(Sa) else: print(Sb)