main = getLine >> getContents >>= print . solve . map (map read . words) . lines solve :: [[Integer]] -> Integer solve [] = 0 solve ([c, d] : xs) = mod (mod d 1000000007 * div (mod c 1000000007+ 1) 2 + solve xs) 1000000007