### main

while true
  n = gets.strip.to_i
  break if n == 0

  chlds = []
  n.times.each do
    d, v = gets.strip.split(' ').map{|s| s.to_i}
    chlds << Rational(v, d)
  end
  #p chlds

  time = chlds.inject(1){|t, c| t.lcm(c.denominator)}
  #p time

  rounds = chlds.map{|c| (c * time).numerator}
  #p rounds

  rgcd = rounds.inject{|rg, r| rg.gcd(r)}
  #p rgcd

  for r in rounds
    puts r / rgcd
  end
end