P, Q, R = map(int, input().split()) A, B, C = map(int, input().split()) x = float('inf') y = -1 for N in range((A - 1) * P + 1, A * P + 1): a = (N + P - 1) // P b = (N + Q - 1) // Q - a c = (N + R - 1) // R - a - b if A == a and B == b and C == c: x = min(x, N) y = max(y, N) if y == -1: print(-1) else: print(x, y)