main = getLine >> getContents >>= prints . solve . map (reads . words) . lines where prints (a, b) = putStrLn $ show a ++ " " ++ show b reads [t, s] = (read t, length s) solve :: [(Int, Int)] -> (Int, Int) solve = foldl ff (0, 0) where ff (x, y) (t, s) | a t > s = (x + s, y) | otherwise = (x + a t, y + s - a t) a t = div (12 * t) 1000