import sys sys.set_int_max_str_digits(10 ** 9) 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)