require 'mathn'

loop {
	n = gets.to_i
	break if n == 0
	a = []
	b = []
	n.times {
		t, c = gets.split.map &:to_i
		a << [-1/t, 1, c]
	}
	a.sort!
	t = 0
	
	until a.empty? && b.empty?
		dt1 = (a.empty? ? Float::INFINITY : -a[0][1] / a[0][0])
		dt2 = (b.empty? ? Float::INFINITY : -b[0][1] / b[0][0])
		dt = (dt1 < dt2 ? dt1 : dt2)
		a[0][1] += dt * a[0][0] if !a.empty?
		(1..a.size-1).each{|i| a[i][1] = [a[i][1] + dt * a[i][0],  a[i-1][1]].max}
		b[0][1] += dt * b[0][0] if !b.empty?
		(1..b.size-1).each{|i| b[i][1] = [b[i][1] + dt * b[i][0],  b[i-1][1]].max}

		f = []
		f << a.shift while !a.empty? && a[0][1] == 0
		f.each{|s| s[1] = 1}
		f.sort!
		b += f

		f = []
		while !b.empty? && b[0][1] == 0
			f << b.shift 
			f.pop if f[-1][2] == 1
		end
		f.each{|s| s[1] = 1; s[2] -= 1}
		f.sort!
		a += f
		t += dt
	end
	p t
}