rm -f tmp; read n; for i in `seq 1 $n`; do read a b; echo $((($a+1)/2*$b)) >> tmp; done; cat tmp | xargs | sed 's/^/\(/' | sed 's/ /+/g' | sed 's/$/)%1000000007/' | bc