main = do 
  (x:y:xs) <- map read . words <$> getLine
  putStrLn . unwords . map show $ solve10000 0 x y


solve10000 m x y
  | x == 0 && y == 0 = [m,0,0]
  | x <= 0 || y <= 0 = [-1,-1,-1]
  | otherwise = 
      let mr = solve10000 (m+1) (x-1) (y-10000)
          sr = solve5000 0 x y
      in if head mr /= -1 then 
        mr 
      else if head sr /= -1 then
        (m:sr)
      else
        [-1,-1,-1]

solve5000 m x y
  | x == 0 && y == 0 = [m,0]
  | x <= 0 || y <= 0 = [-1,-1]
  | otherwise = if x * 1000 == y then [m,y `div` 1000] else solve5000 (m+1) (x-1) (y-5000)

