package main import ( "bufio" "fmt" "os" "strconv" "math" "strings" ) func main() { N := InputInt() var c, d, a int64 mod := int64(math.Pow(10, 9)) + 7 for i := 0; i < N; i++ { s := strings.Split(Input(), " ") c = ((ToInt64(s[0]) + 1) / 2) % mod d = ToInt64(s[1]) % mod a += c * d a %= mod } Print(a) } func Print(x ...interface{}){ l := len(x) - 1 for ii, vi := range x { fmt.Print(vi) if ii == l { fmt.Print("\n") } else { fmt.Print(" ") } } } var sc = bufio.NewScanner(os.Stdin) func Input() string { sc.Scan() return sc.Text() } func InputInt() int { sc.Scan() i, e := strconv.Atoi(sc.Text()) if e != nil {panic(e)} return i } func BinCount(x int) int { s := fmt.Sprintf("%b", x) c := 0 for _, i := range s { if i == '1' {c += 1} } return c } func ToInt(x string) int { i, e := strconv.Atoi(x) if e != nil {panic(e)} return i } func ToInt64(x string) int64 { i, e := strconv.ParseInt(x, 10, 64) if e != nil {panic(e)} return i }