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