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