import Control.Applicative import Control.Monad import Data.List import Data.Monoid f :: [String] -> (Int, Int) f [t, s] = (min count len, max 0 (len-count)) where count = div (12 * read t) 1000 len = length s main = readLn >>= flip replicateM (words <$> getLine) >>= putStrLn . (\(a, b) -> show a ++ (' ':show b)) . foldl (\(a,b) (c,d) -> (a+c,b+d)) (0, 0) . map f