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