sa,pa,xa=map(str,input().split()) sb,pb,xb=map(str,input().split()) if int(pa)int(pb): print(sa) else: print(-1)