S,p,x = input().split() p = int(p) T,q,y = input().split() q = int(q) if p < q: print(T) elif p > q: print(S) else: print(-1)