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)