import Control.Monad main = do n <- readLn :: IO Int -- cs <- map (map read . words) <$> replicateM n getLine cs <- replicateM n $ (map read . words) <$> getLine putStrLn . show $ (solve cs) `mod` (10^9+7) solve :: [[Int]] -> Int solve xs = sum $ map fn xs where fn [x, y] = if even x then (x `div` 2 * y) `mod` (10^9+7) else ((x `div` 2 + 1) * y) `mod` (10^9+7)