import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = breads >>= putStrLn . unwords . fmap show . solve 

solve :: [Int] -> [Int]
solve [n, y]
    | r > 10000 || r < 1000 = [-1, -1, -1]
    | m == 0 && r == 1000 = [0, 0, n]
    | m == 0 && r == 5000 = [0, n, 0]
    | m == 0 && r == 10000 = [n, 0, 0]
    | null res = [-1, -1, -1]
    | otherwise = head res
    where
        (r, m) = y `divMod` n
        res = calc n y

calc :: Int -> Int -> [[Int]]
calc n v = [[x, y, n - x - y] | x <- [0..n], y <- [0..(n - x)], v == 10000 * x + 5000 * y + 1000 * (n - x - y)]

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)