type t = NotYet | Unreach | Best of int * int list ;;

Scanf.scanf "%d %d %s" (fun n m s ->
    let cache = Array.init (n + 1) (fun i -> if s.[i] = '1' then Unreach else NotYet) in
    let rec loop cur =
        if cur = 0 then Best (0, []) else
            if cache.(cur) <> NotYet then cache.(cur) else (
                let rec loop2 d bl bd best =
                    if cur - d < 0 || d > m then (
                        let r = if bl < 0 then Unreach else Best (bl, best @ [ bd ] ) in
                        let () = cache.(cur) <- r in
                        r
                    ) else
                        match loop (cur - d) with
                        | Unreach -> loop2 (d + 1) bl bd best
                        | Best (bl2, best2) ->
                            let bl2 = bl2 + 1 in
                            if bl = -1  then loop2 (d + 1) bl2 d best2 else
                            if bl2 < bl then loop2 (d + 1) bl2 d best2 else
                            if bl2 > bl then loop2 (d + 1) bl  bd best else
                                if best < best2 then loop2 (d + 1) bl bd best
                                                else loop2 (d + 1) bl d  best2
                        | _ -> failwith "??"
                in
                loop2 1 (-1) 0 []
            )
    in
    match loop n with
    | Unreach -> print_endline "-1"
    | Best (bl, best) -> List.iter (Printf.printf "%d ") best; print_newline()
    | _ -> failwith "??"
)