ichiman::Int->Int->[(Int,Int,Int)]
ichiman y m = concat [  map (\(y,z)-> (i,y,z))  (gosen (y - i*10000) (m-i))  | i<-[0 .. (div y 10000)] ]
gosen::Int->Int->[(Int,Int)]
gosen y m =  [ (\ z -> (j,z))  (div  (y - j*5000) 1000)  | j<-[0 .. (div y 5000)], div (y - j*5000) 1000 == m-j]

adjust::[(Int,Int,Int)]->(Int,Int,Int)
adjust [] = (-1,-1,-1)
adjust xs = head xs

main::IO()
main=do
  str<-getLine
  let m:y:[]=map read (words str)
  let (a,b,c)=adjust (ichiman y m)
  putStr (show a)
  putStr "\t"
  putStr (show b)
  putStr "\t"
  putStr (show c)
  putStr "\n"