n = gets.to_i c ,d = [], [] n.times do a, b = gets.split.map(&:to_i) c << a d << b end sum = 0 (0...n).each do |i| sum += (c[i] + 1) / 2 * d[i] end p sum % (10**9+7)