gets; a = gets.split.map(&:to_i) gets; b = gets.split.map(&:to_i) puts (a.reduce { |x, y| Rational(x, y) } / b.reverse.reduce { |x, y| Rational(y, x) } ).to_s.gsub(/\//, ' ')