import Control.Applicative

import Data.Maybe

notes :: [Int]
notes = [10000, 5000, 1000]

make :: [Int] -> Int -> Maybe [Int]
make [] n = if n == 0 then Just [] else Nothing
make (h:r) n = let (d,m) = (n `divMod` h) in (d:) <$> make r m

main = do
    [_,y] <- map read . words <$> getLine
    putStrLn . unwords . map show . fromMaybe [0,0,0] $ make notes y