open Core

let n, y = Scanf.scanf "%d %d" (fun n y -> (n, y / 1000))

let pred i j = (10 * i) + (5 * j) + (n - i - j) = y

let rec find i j =
  if i > n then (-1, -1, -1)
  else if i + j > n then find (i + 1) 0
  else if pred i j then (i, j, n - i - j)
  else find i (j + 1)

let a, b, c = find 0 0

let () = Printf.printf "%d %d %d\n" a b c
