let rec range m n = if m > n then [] else m :: range (m+1) n
let (>>=) xs f = List.map f xs |> List.concat

let solve n y =
  (range 0 n >>= fun a ->
   range 0 (n-a) >>= fun b ->
      if 10000*a + 5000*b + 1000*(n-a-b) = y then [a,b] else [])
  |> function
      | [] -> -1, -1, -1
      | (a, b)::_ -> a, b, n-a-b

let () =
  Scanf.scanf "%d %d\n" @@ fun n y ->
  let a,b,c = solve n y in
  Printf.printf "%d %d %d\n" a b c