p, q, r = map(int, input().split()) a, b, c = map(int, input().split()) b += a c += b pmax = a * p pmin = pmax - p + 1 qmax = b * q qmin = qmax - q + 1 rmax = c * r rmin = rmax - r + 1 left = max(pmin,qmin,rmin) rig = min(pmax,qmax,rmax) # print(left,rig) if left > rig: print(-1) elif left == rig: print(left) else: print(left,rig)