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

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