gets;s=0;$<.map{|c|s+=eval's+=-~%d/2*%d'%gets.split};p s%=10**9+7