@a=map$s+=<>,0..<>;($t+=$_*pop@a)%=1e9+7for<>;print$t,$/