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