a,b,_ = input().split() d,e,_ = input().split() if int(b) < int(e): print(d) elif int(b) > int(e): print(a) else: print(-1)