gets;s=0;$<.map{|c|n,m=c.split.map &:to_i;s+=-~n/2*m};p s%(1e9+7)