gets a = gets.split.map(&:to_i) gets b = gets.split.map(&:to_i) b_numerator, b_denominator = b.partition.with_index { |_, i| i.odd? }.map { |ary| ary.inject(:*) } answer = a[0].quo(a[1..-1].inject(:*)) * (b_numerator.quo(b_denominator)) puts answer.to_s.split('/').join(' ')