n = gets.to_i md = 10 ** 9 + 7 sum = 0 n.times do |i| s = gets.split sum += (s[0].to_f / 2).ceil * s[1].to_i if sum >= md - 1 sum = md - 1 break end end puts sum