p,q,r = map(int,input().split()) a,b,c = map(int,input().split()) n = [] ans = [] for i in range(p*(a-1) + 1,a*p+1): if i%r == 0: num_c = i//r else: num_c = i//r + 1 if num_c - (a+b) == c: n.append(i) for num in n: if num%q == 0: num_b = num//q else: num_b = num//q + 1 if num_b - a == b: ans.append(num) #print(n) if len(ans) == 0: print(-1) else: print(ans[0],ans[-1])