s=0 gets.to_i.times.map{ n,k=gets.split.map(&:to_i) s+=(n+1)/2*k } p s%1000000007