main = do getLine (tp,rest) <- getContents >>= return . foldl1 (\(a,b) (c,d) -> (a+c,b+d)) . map ((\(t:s:_) -> let m = floor(12*(read t)/1000) in if m > length s then (length s, 0) else (m, length s - m) ) . words) . lines putStrLn $ (show tp) ++ " " ++ (show rest)