import qualified Data.ByteString.Char8 as C
import           Data.Maybe ( fromJust, isJust )

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,y] <- getParms
  putStrLn $ f n y

type Yen = Int
type Mai = Int
type Pochi = (Int,Int,Int) -- #s of 10000,5000,1000 bills

pInit :: Yen -> Pochi
pInit y = (a,b,c)
  where
    (a,b') = y  `quotRem` 10000  
    (b,r)  = b' `quotRem` 5000
    c      = r `quot` 1000

maisu :: Pochi -> Int
maisu (a,b,c) = a+b+c

possible' :: Mai -> Yen -> Pochi -> Maybe Pochi
possible' n y p@(a,b,c)
  | n == m = Just p
  | n - m > 3 && b > 0 = possible' n y (a,   b-1, c+5)
  | n - m > 0 && a > 0 = possible' n y (a-1, b+2, c)
  | otherwise = Nothing
  where
    m = maisu p

possible n y = possible' n y (pInit y)

f n y 
  | isJust p  = show a ++ " " ++ show b ++ " " ++ show c
  | otherwise = "-1 -1 -1"
  where
    p@(Just (a,b,c)) = possible n y
