a = input().split() b = input().split() x = int(a[1]) y = int(b[1]) if x == y: print(-1) elif x > y: print(a[0]) else: print(b[0])