a,b,c=input().split() d,e,f=input().split() g=int(b) h=int(e) if g==h: print(-1) else: print(a if g>h else d)