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