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