A = input().split(' ') B = input().split(' ') if int(A[1]) > int(B[1]): print(A[0]) elif int(A[1]) < int(B[1]): print(B[0]) else: print(-1)