package main import "fmt" // 10^9 + 7 const P = 1000000007 func main() { var N int fmt.Scan(&N) var res int64 for i := 0; i < N; i++ { var C, D int64 fmt.Scan(&C, &D) res += ((C/2 + C%2) % P) * (D % P) res %= P } fmt.Println(res) }