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