import Control.Applicative import Control.Monad main :: IO () main = do n <- readLn cds <- replicateM n $ solve . map read . words <$> getLine print $ sum cds `mod` (10^9+7) solve :: [Integer] -> Integer solve [c,d] | c <= 2 = d | otherwise = 2*d