solve :: [(Int,String)] -> (Int,Int) solve = foldl f (0,0) where k = 12 f (a,b) (t,s) = let m = 12 * t `div` 1000 l = length s in (a + min m l, b + max (l-m) 0) main :: IO () main = do n <- readLn :: IO Int xs <- map ((\[a,b] -> (read a, b)) . words) . lines <$> getContents :: IO [(Int,String)] let res = solve xs putStrLn . unwords . map show $ [fst res, snd res]