sa, pa, xa = input().split() sb, pb, xb = input().split() if pa == pb: print(-1) elif pa > pb: print(sa) else: print(sb)