maxExaminees :: [[Integer]] -> Integer maxExaminees = flip mod 1000000007 . sum . map (\(c : d : _) -> (*) d $ (c + 1) `div` 2) main :: IO () main = getLine >> getContents >>= print . maxExaminees . map (map read) . map words . lines