import Data.List (transpose) judge :: [String]-> [Int] judge (t : s : _) = [g, l - g] where l = length s g = min l $ flip div 1000 $ (*) 12 $ read t main :: IO () main = getLine >> getContents >>= putStrLn . unwords . map show . map sum . transpose . map judge . map words . lines