from math import ceil p,q,r = map(int, input().split()) a,b,c = map(int, input().split()) ret = [] for i in range(p*(a-1), p*a+1): if ceil(i/p)==a: if ceil(i/q) - a == b: if ceil(i/r) - (a+b) == c: ret.append(i) if len(ret)==0: print(-1) else: print(min(ret),max(ret))