open System

let [|N;Y|] = stdin.ReadLine().Split(' ') |> Array.map int

let x = Y / 10000
let y = (Y % 10000) / 5000
let z = ((Y % 10000) % 5000) / 1000

let solve i j k =
    let rec subsolve p q r =
        if (p+q+r) = N then 
            (p,q,r)
        else
            match (p,q,r) with
            | _ when q > 0 -> subsolve p (q - 1) (r + 5)
            | _ when p > 0 -> subsolve (p - 1) (q + 2) r
            | _ -> (-1,-1,-1)
    
    subsolve i j k

let printS tuple = 
    match tuple with
    | (x,y,z) -> List.iter (fun x -> stdout.Write((string x) + " ")) [x;y;z]

solve x y z |> printS