p, q, r = gets.split(' ').map(&:to_i) a, b, c = gets.split(' ').map(&:to_i) min, max = (a - 1) * p + 1, a * p if (a + b - 1) * q + 1 <= max && (a + b) * q >= min min = [min, (a + b - 1) * q + 1].max max = [max, (a + b) * q].min else puts '-1' exit 0 end if (a + b + c - 1) * r + 1 <= max && (a + b + c) * r >= min min = [min, (a + b + c - 1) * r + 1].max max = [max, (a + b + c) * r].min else puts '-1' exit 0 end puts "#{min} #{max}"