Sa = input().split() Sb = input().split() if int(Sa[1]) == int(Sb[1]): print("-1") elif int(Sa[1]) > int(Sb[1]): print(Sa[0]) else: print(Sb[0])