A, PA, _ = input().split() B, PB, _ = input().split() if PA == PB: print(-1) elif int(PA) > int(PB): print(A) else: print(B)