import Control.Applicative import Text.Printf main = do n <- fmap (read :: String -> Int) . words <$> getLine xs <- fmap (fmap (read :: String -> Integer) . words) . lines <$> getContents print $ solve xs solve [] = 0 solve ([c,d]:xs) = add (solve xs) (mul ((c+1) `div` 2) d) where add x y = (x + y) `mod` m mul x y = (x * y) `mod` m m = 1000000000 + 7