Takahashi is playing a board game called Sugoroku.
On the board, there are N + 1 squares numbered 0 to N. Takahashi starts at Square 0, and he has to stop exactly at Square N to win the game.
The game uses a roulette with the M numbers from 1 to M. In each turn, Takahashi spins the roulette. If the number x comes up when he is at Square s, he moves to Square s+x. If this makes him go beyond Square N, he loses the game.
Additionally, some of the squares are Game Over Squares. He also loses the game if he stops at one of those squares. You are given a string S of length N + 1, representing which squares are Game Over Squares. For each i (0 \leq i \leq N), Square i is a Game Over Square if S[i] = 1 and not if S[i] = 0.
Find the sequence of numbers coming up in the roulette in which Takahashi can win the game in the fewest number of turns possible. If there are multiple such sequences, find the lexicographically smallest such sequence. If Takahashi cannot win the game, print -1.

-----Constraints-----
 - 1 \leq N \leq 10^5
 - 1 \leq M \leq 10^5
 - |S| = N + 1
 - S consists of 0 and 1.
 - S[0] = 0
 - S[N] = 0

-----Input-----
Input is given from Standard Input in the following format:
N M
S

-----Output-----
If Takahashi can win the game, print the lexicographically smallest sequence among the shortest sequences of numbers coming up in the roulette in which Takahashi can win the game, with spaces in between.
If Takahashi cannot win the game, print -1.

-----Sample Input-----
9 3
0001000100

-----Sample Output-----
1 3 2 3

If the numbers 1, 3, 2, 3 come up in this order, Takahashi can reach Square 9 via Square 1, 4, and 6. He cannot reach Square 9 in three or fewer turns, and this is the lexicographically smallest sequence in which he reaches Square 9 in four turns.

Difficulty: interview

Starter code:

Solutions:
from bisect import bisect_left


N, M = list(map(int, input().split()))
S = input()
good = []
bad = []
for i in range(N + 1):
    if S[i] == "1":
        bad.append(i)
    else:
        good.append(i)

ans = []
cur = N
while True:
    if cur == 0:
        print((" ".join(map(str, ans[::-1]))))
        break
    idx = bisect_left(good, cur - M)
    nx = good[idx]
    ans.append(cur - nx)
    if cur == nx:
        print((-1))
        break
    cur = nx


N, M = map(int, input().split())
S = list(map(int, reversed(input())))
now = 0
ans = []
while now + M < N:
    last = now
    now += M
    while S[now]:
        now -= 1
    if last == now:
        print(-1)
        break
    ans.append(now - last)
else:
    print(*reversed(ans + [N - now]))

import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M = list(map(int, input().split()))
    S = list(input())
    if S[N] == '1' or S[0] == '1':
        print((-1))
    else:
        ans = []
        now = N
        while now > 0:
            for i in range(M, 0, -1):
                j = max(now - i,-1)
                if j>=0 and S[j]=='0':
                    ans.append(i)
                    now = j
                    break
                else:
                    continue
            else:
                print((-1))
                break
        else:
            print((' '.join(map(str, reversed(ans)))))


def __starting_point():
    main()

__starting_point()

import sys
N, M = map(int,input().split())
S = input()
S = S[::-1]
i = 0
ans = []
while i < N:
    flag = 0
    for j in range(M,0,-1):
        if i + j <= N and S[i + j] == '0':
            i += j
            flag = 1
            ans.append(j)
            break
    if flag:
        continue
    print(-1)
    return
ans.reverse()
print(*ans)

from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**9
    n,m=MI()
    s=SI()
    dp=[inf]*(n+1)
    dp[0]=0
    pre=[-1]*(n+1)
    q=deque()
    q.append((0,0))
    for i,c in enumerate(s[1:]):
        if q[0][0]==i-m:q.popleft()
        if c=="0":
            dp[i+1]=q[0][1]+1
            pre[i+1]=q[0][0]
        while q and q[-1][1]>dp[i+1]:q.pop()
        q.append((i+1,dp[i+1]))
    if dp[-1]>=inf:print(-1)
    else:
        ans=[]
        now=n
        while n:
            ans.append(n-pre[n])
            n=pre[n]
        print(*ans[::-1])

main()

n, m = list(map(int, input().split()))
s = input()
si = []

for ch in s:
    if ch == '0':
        si.append(0)
    else:
        si.append(1)

ptr = n
ret = []

while ptr > 0:
    for me in range(m, -1, -1):
        if me == 0:
            print((-1))
            return
        if ptr - me < 0:
            continue
        if si[ptr-me] == 0:
            ret.append(me)
            ptr -= me
            break

ret.reverse()

print((' '.join(map(str, ret))))


def main():
    n, m = list(map(int, input().split()))
    s = input()
    ss = s[::-1]
    if n <= m:
        print(n)
    else:
        cnt = 0
        for i in range(n + 1):
            if s[i] == "1":
                cnt += 1
            else:
                cnt = 0
            if cnt >= m:
                print((-1))
                return
        pos = 0
        res = []
        while n != pos:
            for i in reversed(list(range(m + 1))):
                if pos + i > n:
                    continue
                if ss[pos + i] != "1":
                    pos += i
                    res.append(i)
                    break
        print((*res[::-1]))


def __starting_point():
    main()

__starting_point()

n,m = list(map(int,input().split()))
s = input()
dp = [0]*(n+1)
r = n

for i in range(n-1,-1,-1):
    if int(s[i]) == 1:
        dp[i] = -1
        continue
    while r > i+m:r-=1
    while dp[r] == -1:r -= 1
    if r == i:
        print((-1))
        return
    dp[i] = dp[r]+1
now = 0
ans = []
for i in range(n+1):
    if dp[i] == -1:continue
    if dp[i] != dp[now]:
        ans.append(i-now)
        now = i
print((*ans))
        
    


# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N, M = Scanner.map_int()
    S = Scanner.string()
    pos = N
    ans = []
    while pos > 0:
        for i in range(max(pos - M, 0), pos):
            if S[i] == '0':
                ans.append(pos - i)
                pos = i
                break
        else:
            print((-1))
            return
    print((*ans[::-1]))


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


def __starting_point():
    main()

__starting_point()

n, m = list(map(int, input().split()))
s = input()

one_sequence = 0
for i in range(1, n):
    if s[i] == "1":
        one_sequence += 1
        if one_sequence == m:
            print((-1))
            return
    else:
        one_sequence = 0

pos = n
ans = ""
while pos != 0:
    for i in range(1, m+1)[::-1]:
        if pos-i < 0:
            continue
        if s[pos-i] != "1":
            ans = str(i) + " " + ans
            pos -= i
            break
print(ans)


#146_F
n, m = map(int, input().split())
s = input()[::-1]
ans = []

flg = True
cur = 0
while cur < n and flg:
    for to in range(cur + m, cur, -1):
        if to > n:
            continue
            
        if s[to] == '0':
            ans.append(to - cur)
            cur = to
            break
        
        if to == cur + 1:
            flg = False

if flg:
    print(*ans[::-1])
else:
    print(-1)

# 辞書順最小、というのがポイント
# 最初は小さく進んであとから大きく進む。これは難しい。最初いくつにすれば上手くゴールできるのか不明だ。
# 最初は大きく進んであとから小さくするのはただの貪欲なので簡単。
# したがって、ゴールからスタートに向かって貪欲に逆に進めばよい

n, m = list(map(int, input().split()))
masu = list(input())

idx = n
ans = []

while True:
    valid = False
    next_min_idx = max(idx-m, 0)
    for candi in reversed(list(range(next_min_idx, idx))):
        if masu[candi] == '0':
            destination = candi
            valid = True
    if not valid:
        # mマス連続で1なので必ずゲームオーバー
        print((-1))
        return
    ans.append(idx - destination)
    idx = destination

    if idx == 0:
        break

str_list = list(map(str, ans))
print((' '.join(reversed(str_list))))


from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    s=readline().strip()

    ans=[]
    flag=False
    i=n
    while True:
        max_i=i
        for sa in range(1,m+1):
            if i-sa==0:
                ans.append(sa)
                flag=True
                break
            else:
                if s[i-sa]=="0":
                    max_i=i-sa
        if flag: break
        else:
            if max_i!=i:
                ans.append(i-max_i)
                i=max_i
            else:
                break

    if flag:
        ans.reverse()
        print(*ans)
    else:
        print(-1)

def __starting_point():
    main()
__starting_point()

import sys
def input(): return sys.stdin.readline().strip()

def main():
    N, M = map(int, input().split())
    S = input()

    def isOK(index):
        return S[index] == "0"
    
    ans = []
    now = N
    while now:
        for step in range(min(now, M), -1, -1):
            if step == 0:
                print(-1)
                return

            if isOK(now-step):
                ans.append(step)
                now -= step
                break
    print(*ans[::-1], sep=" ")



def __starting_point():
    main()
__starting_point()

N, M = map(int, input().split())
S = input()[::-1]
l = []
p = 0

chk = True
while p<N:
    for i in range(1, min(M, N-p)+1)[::-1]:
        if S[p+i]=="0":
            break
    else:
        print(-1)
        chk = False
        break
    l.append(i)
    p += i

if chk:
    l.reverse()
    print(*l)

#!/usr/bin python3
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
s = input()
s = s[::-1]
INF = 2*n

if '1'*m in s:
    print(-1)
    return

dp = [-1] * (n+1)
nw = 0
st = 0
nst = 0
ret = []
while nw < (n+1):
    if s[nw]=='1':
        dp[nw] = INF
    else:
        dp[nw] = dp[st] + 1
        nst = nw
    nw += 1
    if nw == n+1:
        ret.append(nst-st)
    elif nw > st + m:
        ret.append(nst-st)
        st = nst
print(' '.join(map(str,ret[::-1])))

import sys
input = sys.stdin.readline

N, M = list(map(int, input().split()))
S = list(input().rstrip())

def cost(S):
    minCost = [-1]*(N+1)
    minCost[0] = 0
    ind = 1
    for i,s in enumerate(S):
        if s == "1":
            continue
        while i < ind <= min(i+M, N):
            if S[ind] == "0":
                minCost[ind] = minCost[i] + 1
            ind += 1
    return minCost

M1 = cost(S)
M2 = cost(S[::-1])[::-1]
if M1[-1] == -1:
    print((-1))
else:
    C = M1[-1]
    Inds = [10**14]*(C+1)
    for i, (m1, m2) in enumerate(zip(M1, M2)):
        if m1 + m2 == C:
            Inds[m1] = min(Inds[m1], i)
    ans = []
    for i1, i2 in zip(Inds, Inds[1:]):
        ans.append(i2-i1)
    print((*ans))


import bisect

N, M = list(map(int, input().split()))
S = input()

ok = True
cnt = 0
for c in S:
    if c == "1":
        cnt += 1
        if cnt == M:
            ok = False
            break
    else:
        cnt = 0

# 後ろから見て、各マスからもっとも近い右側の0の位置を格納(S[i]=0ならi)
ngo_pos = [0 for _ in range(N+1)]
most_neighbor_zero_pos = N
for i in range(N, -1, -1):
    if S[i] == "0":
        ngo_pos[i] = i
        most_neighbor_zero_pos = i
    else:
        ngo_pos[i] = most_neighbor_zero_pos

if not ok:
    print((-1))
else:
    ans = []
    pos = N
    while pos > 0:
        npos = ngo_pos[max(0, pos-M)]
        ans.append(pos-npos)
        pos = npos
    print((" ".join(map(str, ans[::-1]))))


n, m = map(int, input().split())
s = input()
dp = [-1 for _i in range(n+1)]
dp[0] = 0
f = 0
from collections import deque
q = deque([0])
c = 0
for i in range(1, n+1):
    if s[i]=="0":
        c = 0
        while i-f > m:
            f = q.popleft()
        dp[i] = f
        q.append(i)
    elif c < m-1:
        c += 1
    else:
        break

if dp[n] >= 0:
    r = []
    p = n
    while p > 0:
        nex = dp[p]
        r.append(p-nex)
        p = nex
    print(*r[::-1])
else:
    print(-1)

n,m = map(int,input().split())
s = input()
s = s[::-1]
ans = []
cur = 0
c = 0
#while cur < n and c < 100:
while cur < n:
    d = n - cur
    r = min(m,d)
    cnt = 0
    for i in range(r):
        x = r - i
        if s[cur + x] == '0':
            ans.append(x)
            cur += x
            #print(x)
            break
        else:
            cnt += 1
    if cnt == r:
        print(-1)
        return
    #c += 1
    #print(cur,r)


print(*ans[::-1])

#!python3

from collections import deque

LI = lambda: list(map(int, input().split()))

# input
N, M = LI()
S = input()

INF = 10 ** 6


def main():
    w = [(INF, INF)] * (N + 1)
    w[0] = (0, 0)
    # (cost, index)
    dq = deque([(0, 0)])
    for i in range(1, N + 1):
        if i - dq[0][1] > M:
            dq.popleft()
        if len(dq) == 0:
            print((-1))
            return
        if S[i] == "0":
            w[i] = (dq[0][0] + 1, i - dq[0][1])
            dq.append((w[i][0], i))

    ans = []
    x = N
    while x > 0:
        d = w[x][1]
        ans.append(d) 
        x -= d
    ans = ans[::-1]
    print((*ans))


def __starting_point():
    main()

__starting_point()

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    s = input().rstrip()
    s = s[::-1]
    # 右から0, 1, 2...とした時のセーフな位置
    safe = []
    for i in range(n+1):
        if s[i] == '0':
            safe.append(i)
    res = []

    pos = 0
    while pos < n:
        pre = pos
        pos += m
        if pos >= n:
            res.append(str(n-pre))
            break
        idx = bisect_left(safe, pos)
        if safe[idx] > pos:
            pos = safe[idx-1]
        if pre == pos:
            print(-1)
            return
        res.append(str(pos-pre))
    print(*res[::-1])

def __starting_point():
    main()
__starting_point()

from bisect import bisect_left
N, M = list(map(int, input().split()))
s = input()
safe = []
cnt = 0
for i, m in enumerate(s):
  if m=='1':
    cnt += 1
    if cnt==M:
      print((-1))
      break
  else:
    safe += [i]
    cnt = 0
else:
  ps = N
  ans = []
  while ps!=0:
    ind = bisect_left(safe,ps-M)
    ans += [ps-safe[ind]]
    ps = safe[ind]
  print((*ans[::-1]))
    


import sys
N, M = list(map(int, input().split()))
S = [int(c) for c in input()][::-1]

c = 0
path = []
while c < N:
    g = c+M if c+M < N else N
    for m in range(g, c, -1):
        if S[m] == 1:
            continue
        else:
            path.append(m-c)
            c = m
            break
    else:
        if c < N:
            print((-1))
            return

print((*path[::-1]))



N,M = map(int,input().split())
S = list(input())
#print(S)
S.reverse()

if S[0] == 1 or S[-1] == 1:
    det = -1
else:
    det = 0
    count = 0
    data = []
    for i in range(N+1):
        if S[i] == "0":
            data.append(count+1)
            count = 0
        else:
            count += 1
        if count == M:
            det = -1
            break
    #print(data)
    
if det != -1:
    ans = []
    count = 0
    for i in range(1,len(data)):
        if count + data[i] > M:
            ans.append(count)
            count = data[i]
        else:
            count += data[i]
    ans.append(count)
    ans.reverse()
    print(" ".join(map(str,ans)))

else:
    print(-1)

n,m = list(map(int, input().split()))
s = input()
now = 0
MIN = 0
ans = []
while now < n:
  for i in range(min(n-now,m),0,-1):
    nex = now + i
    if s[nex] == "0":
      now = nex
      MIN += 1
      break
  else:
    print((-1))
    return
now = 0
while now < n:
  for i in range(min(n-now,m),0,-1):
    nex = now + i
    if s[n-nex] == "0":
      now = nex
      ans.append(i)
      break
print((*reversed(ans)))


n,m=map(int,input().split())
s=input()[::-1]
ans=[]
pos=0
while pos!=n:
  for i in range(min(n-pos,m),0,-1):
    if s[pos+i]=='0':
      ans.append(i)
      pos+=i
      break
  else:
    print(-1)
    return
print(*ans[::-1])

n,m=map(int,input().split())
*s,=map(int,input()[::-1])
i=0
a=[]
while i<n:
    j=min(n,i+m)
    while s[j]:j-=1
    if j==i:
        print(-1)
        return
    a+=j-i,
    i=j
print(*a[::-1])

import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M = list(map(int, input().split()))
    S = list(input())
    if S[N] == '1' or S[0] == '1':
        print((-1))
    else:
        ans = []
        now = N
        while now > 0:
            for i in range(M, 0, -1):
                j = now - i
                if j>=0:
                    if S[j]=='0':
                        ans.append(i)
                        now = j
                        break
                else:
                    continue
            else:
                print((-1))
                break
        else:
            print((' '.join(map(str, reversed(ans)))))


def __starting_point():
    main()

__starting_point()

n, m = map(int, input().split())
s = input()[::-1]
ans = []
now = 0
while now<n:
    for i in range(min(m, n-now), 0, -1):
        if s[now+i]=='0':
            now += i
            ans.append(i)
            break
    else:
        print(-1)
        return
print(*ans[::-1])

import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    S = input().strip("\n")
    now = N
    ans = []
    while now > 0:
        for i in reversed(range(1, M+1)):
            if now - i < 0: continue
            elif S[now - i] == "0":
                ans.append(i)
                now -= i
                break
        else: 
            print(-1)
            break
    else: 
        A = [int(ans[-1 - i]) for i in range(len(ans))]
        print(" ".join(map(str, A)))

    return 0

def __starting_point():
    solve()
__starting_point()

n, m = list(map(int,input().split()))
s = list(input())

s.reverse()
ng = False
c = 0
ans = []
while ng == False and c < n:
    for i in range(m, 0, -1):
        if c+i < n+1 and s[c+i] == '0':
            c += i
            ans.append(str(i))
            break
        elif i == 1:
            ng = True
if ng:
    print((-1))
else:
    ans.reverse()
    print((' '.join(ans)))


def main():
  N,M=list(map(int,input().split()))
  S=input()

  c,l=N,[]
  while c>0:
    for i in range(M,0,-1):
      if i<=c and S[c-i]=='0':
        l+=[i]
        c-=i
        break
    else:
      l=[-1]
      break
  print((*l[::-1]))

main()


import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
s = list(ns())
s = s[::-1] #n+1

ans = []
i = 0
while True:
    j = i+m if i+m < n else n
    for k in reversed(range(i+1,j+1)):
        if s[k] == '0':
            ans.append(k-i)
            i = k
            break
    else:
        print(-1)
        return
    if i == n:
        break

print(*ans[::-1],sep=' ')

N,M=map(int, input().split())
S=list(input())
T=S[::-1]
D=[0]*N
if N<=M:
  print(N)
  return
r=0
renzoku,ma=0,0
for i in range(1,N+1):
  if S[i]=='1':
    renzoku+=1
  else:
    ma=max(ma,renzoku)
    renzoku=0
if ma>=M:
  print(-1)
  return

for i in range(1,M+1):
  if T[i]!='1':
    D[i]=1
    r=i
  else:
    D[i]=100000
ans=[r]

while r+M<N:
  for i in range(M,0,-1):
    if T[r+i]=='0':
      ans.append(i)
      r+=i
      break
  
ans.append(N-r)
print(*ans[::-1])

n, m = map(int, input().split())
S = list(input())
"""
9 3
0001000100
0010001000
3  2   3 1  
"""
S_r = S[::-1] + ["0"] #スタートのぶん付け足し
ans = []
now = 0
while now < n:
    flg = True
    for i in range(m,0,-1):
        if now + i <= n and S_r[now+i] == "0":
            ans.append(i)
            now += i
            flg = False
            break
    if flg:
        print(-1)
        return

print(*ans[::-1])

#!/usr/bin/env python3
import sys
def input(): return sys.stdin.readline().rstrip()

# ライブラリ参照https://atcoder.jp/contests/practice2/submissions/16580070


class SegmentTree:

    __slots__ = ["func", "e", "original_size", "n", "data"]

    def __init__(self, length_or_list, func=max, e=-10**18):
        self.func = func
        self.e = e
        if isinstance(length_or_list, int):
            self.original_size = length_or_list
            self.n = 1 << ((length_or_list - 1).bit_length())
            self.data = [self.e] * (self.n*2)
        else:
            self.original_size = len(length_or_list)
            self.n = 1 << ((self.original_size - 1).bit_length())
            self.data = [self.e] * self.n + length_or_list + \
                [self.e] * (self.n - self.original_size)
            for i in range(self.n-1, 0, -1):
                self.data[i] = self.func(self.data[2*i], self.data[2*i+1])

    def replace(self, index, value):
        index += self.n
        self.data[index] = value
        index //= 2
        while index > 0:
            self.data[index] = self.func(
                self.data[2*index], self.data[2*index+1])
            index //= 2

    def folded(self, l, r):
        left_folded = self.e
        right_folded = self.e
        l += self.n
        r += self.n
        while l < r:
            if l % 2:
                left_folded = self.func(left_folded, self.data[l])
                l += 1
            if r % 2:
                r -= 1
                right_folded = self.func(self.data[r], right_folded)
            l //= 2
            r //= 2
        return self.func(left_folded, right_folded)

    def all_folded(self):
        return self.data[1]

    def __getitem__(self, index):
        return self.data[self.n + index]

    def max_right(self, l, f):
        # assert f(self.e)
        if l >= self.original_size:
            return self.original_size
        l += self.n
        left_folded = self.e
        while True:
            # l //= l & -l
            while l % 2 == 0:
                l //= 2
            if not f(self.func(left_folded, self.data[l])):
                while l < self.n:
                    l *= 2
                    if f(self.func(left_folded, self.data[l])):
                        left_folded = self.func(left_folded, self.data[l])
                        l += 1
                return l - self.n
            left_folded = self.func(left_folded, self.data[l])
            l += 1
            if l == l & -l:
                break
        return self.original_size

    # 未verify
    def min_left(self, r, f):
        # assert f(self.e)
        if r == 0:
            return 0
        r += self.n
        right_folded = self.e
        while True:
            r //= r & -r
            if not f(self.func(self.data[r], right_folded)):
                while r < self.n:
                    r = 2 * r + 1
                    if f(self.func(self.data[r], right_folded)):
                        right_folded = self.func(self.data[r], right_folded)
                        r -= 1
                return r + 1 - self.n
            if r == r & -r:
                break
        return 0


def minindex(x, y):
    if x[0] <= y[0]:
        return x
    else:
        return y


def main():
    n, m = map(int, input().split())
    S = list(map(lambda x: 0 if x == '0' else 10**10, list(input())))
    roots = [10**10]*(n+1)
    for i in range(1, min(m+2, n+1)):
        if S[i] < 10**9:
            S[i] = 1
            roots[i] = 0
    S = [[s, i] for i, s in enumerate(S)]
    seg = SegmentTree(S, minindex, [10**12, 10**12])
    for i in range(m+1, n+1):
        if S[i][0] < 10**9:
            dist, masu = seg.folded(i-m, i)
            roots[i] = masu
            seg.replace(i, [dist+1, i])
    #print(seg.data[16:])
    #print(roots)
    if seg.folded(n, n+1)[0] > 10**9:
        print(-1)
    else:
        ans = []
        while n > 0:
            ans.append(n-roots[n])
            n = roots[n]
        print(*ans[::-1], sep=" ")


def __starting_point():
    main()
__starting_point()

N, M = list(map(int, input().split()))
S = input()
prev = N
pos = N
ans = []
while pos > 0:
    for i in range(M, 0, -1):
        if pos - i >= 0 and S[pos - i] == '0':
            ans.append(i)
            pos -= i
            break
    if pos == prev:
        ans = [-1]
        break
    prev = pos
print((*ans[::-1]))


import sys

N, M = map(int, input().split())
S = input()
tmp = 0
for i in range(N+1):
	if S[i] == '1':
		tmp += 1
		if tmp == M:
			print(-1)
			return
	else:
		tmp = 0

ans = []

i = N
while i > M:
	ind = S[i-M:i].find('0')
	ans.append(M-ind)
	i -= M - ind

ans.append(i)

print(*ans[::-1])

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: list(map(int, readline().split()))
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: list(map(int, read().split()))


def main():
    N, M = in_nn()
    S = in_s()

    ans = []
    now = N
    while now > 0:
        next = -1
        end = max(0, now - M)
        for i in range(now - 1, end - 1, -1):
            if S[i] == '0':
                next = i
        if next == -1:
            print((-1))
            return
        else:
            ans.append(now - next)
            now = next

    ans = ans[::-1]
    print((' '.join(map(str, ans))))


def __starting_point():
    main()

__starting_point()

N,M = map(int,input().split())
S = input()[::-1]

if M >= N:
    print(N)
    return

p = -1
for i in reversed(range(1,M+1)):
    if S[i] == "0":
        p = i
        break

if p == -1:
    print(-1)
    return

ps = [p]
while 1:
    tmp = -1
    for i in reversed(range(ps[-1]+1,ps[-1]+M+1)):
        try:
            if S[i] == "0" or i == N:
                ps.append(i)
                tmp = i
                break
        except:
            pass
    if tmp == -1:
        print(-1)
        return
    if ps[-1] == N:
        break

pp = ([ps[i+1]-ps[i] for i in range(len(ps)-1)])[::-1] + [ps[0]]
print(*pp)

n, m = map(int, input().split())
s = input()
out_s='1'*(m)
if out_s in s:
    print(-1)
    return
s = s[::-1]
if s[0] == "1":
    print(-1)
    return
pre = [-1] * (n + 1)
stack = [0]
while stack:
    now = stack.pop()
    if now == n:
        break
    for i in range(1, m + 1):
        tsugi = now + i
        if tsugi > n:
            continue
        if s[tsugi] == "1":
            continue
        pre[tsugi] = now
        stack.append(tsugi)
else:
    print(-1)
    return
ato = n
mae = pre[n]
ans = []
while mae >= 0:
    ans.append(ato - mae)
    ato = mae
    mae = pre[ato]
print(*ans, sep=" ")


from bisect import bisect_right

N, M = list(map(int, input().split()))
S = [N - i for i, s in enumerate(input()) if s == '0']
S = S[::-1]

ans = []
now = 0
while now < N:
    i = bisect_right(S, now + M) - 1

    if S[i] == now:
        print('-1')
        return

    ans.append(S[i] - now)
    now = S[i]

print((*ans[::-1]))


n,m = map(int,input().split())
s = input()[::-1]

#まず何手でクリアできるかを把握する
count = 1
inf = 10**10

#ゴールまでその地点から何手で到達できるかを記録する
length = [inf]*(n+1)
length[0] = 0
now = 0
flag = True

while flag:
    ok = 0
    for i in range(1,m+1):
        if s[now+i] == "1":
            continue
        length[now+i] = count
        ok = now+i
        if now+i == n:
            flag = False
            break
    if ok == 0:
        print(-1)
        return
    now = ok
    count += 1

count -= 2

#スタートからの軌跡を格納するリスト
li = []
length = length[::-1]
point = 0

for i,j in enumerate(length):
    if j == count:
        count -= 1
        li.append(point)
        point = 0
    point += 1

print(*li)

N,M = map(int,input().split())
S = input()

ans = []
i = N
while i>0:
    if i <= M:
        ans.append(i)
        break
    for j in range(M,0,-1):
        if S[i-j]=='1': continue
        ans.append(j)
        i -= j
        break
    else:
        print(-1)
        return
print(*ans[::-1])

n, m = list(map(int, input().split()))
s = list(input())[::-1]
i = 0
ans = 0
ans_list = []
while i < n:
    l = s[i+1:i+m+1]
    for next in range(m-1, -2, -1):
        if next == -1:
            print((-1))
            return
        if next > len(l)-1:
            continue
        if l[next] == '0':
            ans_list.append(next+1)
            i += next+1
            break
print((' '.join(map(str, ans_list[::-1]))))


# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo


@mt
def slv(N, M, S):

    from functools import lru_cache
    @lru_cache(maxsize=None)
    def dfs(x):
        if x == 0:
            return []

        for i in range(M, 0, -1):
            if 0 <= x-i and S[x-i] == '0':
                r = dfs(x-i)
                if r is not None:
                    r.append(i)
                    return r
        return None
    ans = dfs(N)
    if ans is None:
        ans = [-1]
    return ans




def main():
    N, M = read_int_n()
    S = read_str()
    print(*slv(N, M, S))


def __starting_point():
    main()

__starting_point()

N, M = list(map(int, input().split()))
S = input()
S = S[::-1]
l = len(S)

idx = 0
answer = []
flag = False
while True:
    if l - idx > M:
        m = M
    else:
        m = l - idx - 1
        flag = True
    if S[idx + m] == '0':
        answer.append(m)
        idx += m
        if flag:
            break
    else:
        while S[idx + m] == '1':
            m -= 1
            if m == 0:
                print((-1))
                return
        answer.append(m)
        idx += m

if answer[-1] == 0:
    answer.pop()
answer = answer[::-1]
print((' '.join(map(str, answer))))


n, m = map(int, input().split())
s = input()
s = ''.join(reversed(s))
ans = []
index = 0
while index < n:
    next_index = -1
    for j in range(min(index + m, n), index, -1):
        if s[j] == '0':
            next_index = j
            break
    if next_index == -1:
        ans = [-1]
        break
    ans.append(next_index - index)
    index = next_index 
print(' '.join(list(map(str, list(reversed(ans))))))

N, M = list(map(int, input().split()))
S = input()

p = N
prev = N
flag = True
ans = []
for i in range(N, -1, -1):
    if (prev - i) > M:
        ans.append(prev - p)
        prev = p
        if (prev - i) > M:
            flag = False
            break
    if S[i] == "0":
        p = i
ans.append(prev)
if flag:
    print((" ".join(map(str, ans[::-1]))))
else:
    print((-1))


# AtCoder Beginner Contest 146
# F - Sugoroku
# https://atcoder.jp/contests/abc146/tasks/abc146_f
import sys
N, M = list(map(int, input().split()))
*S, = list(map(int, input()))
S.reverse()

i = 0
ans = []
while i < N:
    for m in range(M, 0, -1):
        if i+m <= N and S[i+m] == 0:
            i += m
            ans += [m]
            break
    else:
        print((-1))
        return

print((*ans[::-1]))


def main():
    N, M = list(map( int, input().split()))
    S = [ int(s) for s in input()][::-1]
    ANS = []
    t = 0
    while t < N:
        for i in range( min(M, N-t),0,-1):
            if S[t+i] == 0:
                ANS.append(i)
                t += i
                break
        else:
            print((-1))
            return
    if sum(ANS) == N:
        print(( " ".join( map( str,ANS[::-1]))))
    else:
        print((-1))
                

def __starting_point():
    main()

__starting_point()

import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=input()
ans=[]
def f(i,j):
    if i==0:
        print(" ".join(map(str,ans[::-1])))
        return
    if j>i:
        j=i
    while s[i-j]=="1":
        j-=1
    if j==0:
        print(-1)
        return
    ans.append(j)
    f(i-j,m)
f(n,m)

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
S = list(sr())[::-1]
answer = []
count = 0
cur = 0
while True:
    next = cur
    for i in range(M, 0, -1):
        if cur + i > N:
            continue
        if S[cur+i] == '0':
            count += 1
            next = cur + i
            answer.append(i)
            break
        else:
            continue
    if next == cur:
        print((-1)); return
    cur = next
    if next == N:
        break

answer = answer[::-1]
print((*answer))


def main():
    N, M = list(map(int, input().split()))
    *G, = list(map(int, input()))

    ans = []
    cur = N
    ecur = cur - 1
    while cur > 0:
        ncur = cur
        while (cur - ecur) <= M and ecur >= 0:
            if G[ecur] == 0:
                ncur = ecur
            ecur -= 1

        if ncur == cur:
            print((-1))
            return

        ans.append(cur - ncur)
        cur = ncur

    ans.reverse()

    print((*ans))


def __starting_point():
    main()

__starting_point()

N,M=map(int, input().split())
S=input()
now=S[N-1]
dp=[float("INF")]*(N+1)
dp[N]=0
nowmin=0
right=N
for left in range(N-1,-1,-1):
    while right-left>M or S[right]=="1":
        right-=1
        nowmin=dp[right]
    if right<=left:
        print(-1)
        return
    if S[left]=="1":
        continue
    else:
        dp[left]=1+nowmin
#print(dp)
#print(dp[0])
now=dp[0]
nowi=0
"""
if now==float("INF"):
    print(-1)
    return
"""
for i in range(1,N+1):
    if now>dp[i]:
        print(i-nowi, end=" ")
        now=dp[i]
        nowi=i


N,M=map(int,input().split())
S=input()
S=S[::-1]
now = 0
ok=1
history = []
while True:
  for i in range(min(M, N-now),0,-1):
    if S[now+i] == '0':
      now += i
      history.append(str(i))
      break
    if i==1:
      print(-1)
      ok=0
      break
  if ok==0:break
  if now == N:break

if ok==1:print(' '.join(history[::-1]))

def main():
    n, m = map(int, input().split())
    s = input().rstrip()
    ans = []
    x = n
    f = True
    while x > 0 and f:
        for i in reversed(range(m+1)):
            if i == 0:
                f = False
                break
            if s[max(0, x-i)] == '0':
                if x-i < 0:
                    ans.append(x)
                else:
                    ans.append(i)
                x = max(0, x-i)
                break
    if f:
        for v in reversed(ans):
            print(v, end=" ")
        print("")
    else:
        print("-1")

def __starting_point():
    main()
__starting_point()

N,M=map(int, input().split())
S=list(input())
T=S[::-1]
D=[0]*N
if N<=M:
  print(N)
  return
renzoku,ma=0,0
for i in range(1,N+1):
  if S[i]=='1':
    renzoku+=1
  else:
    ma=max(ma,renzoku)
    renzoku=0
if ma>=M:
  print(-1)
  return
r=0
for i in range(1,M+1):
  if T[i]!='1':
    r=i
ans=[r]

while r+M<N:
  for i in range(M,0,-1):
    if T[r+i]=='0':
      ans.append(i)
      r+=i
      break
  
ans.append(N-r)
print(*ans[::-1])


N, M = list(map(int, input().split()))
s = input()
ans = []
cur = N
while cur != 0:
    for step in range(M, 0, -1):
        if cur - step < 0:
            continue
        if s[cur-step] == '1':
            continue
        ans.append(step)
        cur -= step
        break
    else:
        print((-1))
        return
print((*ans[::-1]))


n,m=map(int,input().split())
s=input()[::-1]
i=0
ans=[]
while i<n:
  for j in range(min(n-i,m),0,-1):
    if s[i+j]=="0":
      ans.append(j)
      i+=j
      break
    if j==1:print(-1);return
print(*ans[::-1])

n, m = map(int, input().split())
s = input()

l = []
cur = n

while cur > 0:
  position = cur
  cur = max(0, cur - m)
  while s[cur] == "1":
    cur += 1
  if cur == position:
    print(-1)
    return
  l.append(str(position - cur))
l.reverse()
print(" ".join(l))

n, m = map(int, input().split())
s = input()
n += 1

pos = [n - 1]
ind = n - 1
while True:
    tmp = -1
    for i in range(1, m + 1):
        if s[max(ind - i, 0)] == "0":
            tmp = max(ind - i, 0)
    if tmp == -1:
        print(-1)
        return
    pos.append(tmp)
    ind = tmp
    if ind == 0:
        break
tmp = pos[::-1]
ans = []
for i in range(len(tmp) - 1):
    ans.append(tmp[i + 1] - tmp[i])
print(*ans)

#F sugoroku
#貪欲にNからM以下の範囲で戻れるだけ戻ることにする
safe=[]
n,m=map(int,input().split())
field=list(input())
for i in range(n+1):
    if field[i]=="0":
        safe.append(i)
start=n

import bisect

deque=[]
flag=True
while start>0:
    if start>=m:
        index=bisect.bisect_left(safe,start-m)
        if safe[index]!=start:
            deque.append(start-safe[index])
            start=safe[index]           

        elif safe[index]==start:
            flag=False
            start=0              
    else:
        deque.append(start)
        start=0
if flag:
    deque=deque[::-1]
    print(*deque)
else:
    print(-1)        

n,m = list(map(int,input().split()))
s = list(input())
s.reverse()
for i in range(m):
    s.append("1")
p = 0
ans = []
while p < n:
    p += m
    cnt = m
    while s[p] == "1":
        p -= 1
        cnt -= 1
        if cnt == 0:
            print((-1))
            return
    ans.append(cnt)
ans.reverse()
print((*ans))





import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
S = sr()
# マスNからスタート
cur = N
answer = []
while cur > 0:
    for x in range(M, 0, -1):
        if cur - x < 0 or S[cur - x] == '1':
            continue
        answer.append(x)
        cur -= x
        break
    else:
        print((-1))
        return

answer = answer[::-1]
print((*answer))
# 53


n, m = map(int, input().split())
sugoroku = input()[::-1]

cnt = 0
pos = 0
tmp = 0
lst = []
while pos != n:
    pos += 1
    cnt += 1
    if cnt == m:
        if sugoroku[pos] == "0":
            lst.append(cnt)
            cnt = 0
        else:
            if tmp == 0:
                print(-1)
                return
            lst.append(tmp)
            cnt -= tmp
            tmp = 0
    else:
        if sugoroku[pos] == "0":
            tmp = cnt
if cnt != 0:
    lst.append(cnt)
for num in lst[::-1]:
    print(num, end = " ")


import sys
input = lambda: sys.stdin.readline().rstrip()
 
n, m = list(map(int, input().split()))
s = input()
ans = []
s = s[::-1]
now = 0
while True:
    for i in range(m, -1, -1):
        if i == 0:
            print((-1))
            return
        if now + i <= n and s[now + i] == "0":
            now += i
            ans.append(i)
            if now == n:
                print((*ans[::-1]))
                return
            else:
                break
    
        


N, M = map(int, input().split())
S = input()

p = N
ans = []
ans_ok = True
while True:
    if p <= M:
        ans.append(p)
        p -= p
        break
    check = False
    for i in range(M, 0, -1):
        if S[p-i] == '0':
            check = True
            ans.append(i)
            p -= i
            break
    if not check:
        ans_ok = False
        break
if ans_ok:
    print(' '.join(map(str, ans[::-1])))
else:
    print(-1)

import sys

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    S = input().strip()

    if S.count("1" * M) > 0:
        print((-1))
        return

    ans = []
    r = N
    while r > 0:
        li = N - 1
        for diff in range(1, M + 1):
            if r - diff < 0:
                break
            if S[r - diff] == "0":
                li = r - diff
        ans.append(r - li)
        r = li
        if r == 0:
            break

    ans.reverse()
    print((*ans))



def __starting_point():
    main()

__starting_point()

n, m = map(int, input().split())
s = input()
roulette = []

cur = n
while cur > m:
  for a in range(m):
    if s[cur - m + a] == '0':
      roulette.append(m - a)
      cur = cur - m + a
      break
  else:
    print(-1)
    break
else:
  roulette.append(cur)
  print(' '.join(map(str, roulette[::-1])))

N, M = map(int, input().split())
S = input()
pos = N
ans = []
while pos > 0:
    for i in range(M, 0, -1):
        if pos - i < 0 or S[pos - i] == '1':
            continue
        ans.append(i)
        pos -= i
        break
    else:
        ans = [-1]
        break
print(*ans[::-1])

n,m=list(map(int,input().split()))
s=list(map(int,list(input())))
ans=[]
i=n
while i>0:
  j=max(0,m-i)
  while s[i-(m-j)]!=0:
    j+=1
    if j==m:
      print((-1))
      return
  ans.append(m-j)
  i-=(m-j)
ans.reverse()
print((' '.join(map(str,ans))))


from bisect import bisect_right

N, M = map(int, input().split())
S = [-i for i, s in enumerate(input()) if s == '0']
S = S[:: -1]

ans = []
now = 0
while S[now] != 0:
    to = bisect_right(S, S[now] + M) - 1

    if to == now:
        print('-1')
        return
    ans.append(S[to] - S[now])
    now = to

ans = ans[:: -1]
print(*ans)

N,M = map(int, input().split())
S = list(input())

cnt,cnt1 = 0,0
for s in S:
    if s == "1":
        cnt1 += 1
    else:
        cnt = max(cnt, cnt1)
        cnt1 = 0
if cnt >= M:
    print(-1)
    return

ans = []
pos = N
while pos > 0:
    for m in range(M, 0, -1):
        if pos - m < 0: continue
        if S[pos - m] == "1": continue

        ans.append(m)
        pos -= m
        break

print(*ans[::-1])

import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    S = input().strip("\n")
    ans = deque()
    current = N
    while current > 0:
        for i in reversed(range(1, M+1)):
            if current - i >= 0 and S[current - i] == "0":
                ans.appendleft(i)
                current -= i
                break
        else: break
    if current > 0: print(-1)
    else: print(*ans, sep=" ")


    return 0

def __starting_point():
    solve()
__starting_point()

from bisect import bisect_left

N, M = list(map(int, input().split()))
S = [i for i, s in enumerate(input()) if s == '0']

ans = []
now = N
while now > 0:
    nxI = bisect_left(S, now - M)
    nx = S[nxI]

    if nx == now:
        print((-1))
        return

    ans.append(now - nx)
    now = nx

print((*ans[::-1]))


import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return list(map(int, input().split()))
def read_index(): return [int(x) - 1 for x in input().split()]
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, M = read_values()
    S = input().strip()[::-1]
    P = []
    t = 0
    tmp = 1
    for s in S[1:]:
        if s == "0":
            t = tmp
        
        tmp += 1
        if tmp > M:
            if t == 0:
                print((-1))
                return

            P.append(str(t))
            tmp -= t 
            t = 0
    
    if t != 0:
        P.append(str(t))
    print((" ".join(P[::-1])))


def __starting_point():
    main()

__starting_point()

N, M = list(map(int, input().split()))
S = input()

lst = []
i = N
while i > 0:
    for j in range(min(i, M), 0, -1):
        if S[i - j] == '0':
            lst.append(j)
            i -= j
            break
    else:
        print((-1))
        return
print((' '.join(map(str, reversed(lst)))))


n,m=map(int,input().split())
s,l=input(),[]
while n>0:
 for i in range(m,0,-1):
  if i<=n and s[n-i]=="0":l.append(i);n-=i;break
 else:print(-1);return()
print(*l[::-1])

N, M = list(map(int, input().split()))
S = input()
S = S[::-1]

dp = [-1] * (N+1)
dp[0] = 0

pos = 0
while pos < N:

    p = pos
    update = False

    for i in range(1, M + 1):
        if p + i > N:
            break
        if S[p + i] == "0":
            update = True
            pos = p + i
            dp[pos] = dp[p] + 1

    if not update:
        break

if dp[N] == -1:
    print((-1))
    return

dp = dp[::-1]
num = dp[0]
ans = []
pos = 0

while num > 0:
    for i in range(1, M + 1):
        if dp[pos + i] == num - 1:
            num -= 1
            pos += i
            ans.append(str(i))
            break

ans = " ".join(ans)
print(ans)


def main():
    
    n,m = list(map(int,input().split()))
    l = list(input())[::-1]
    ans = []
    i = 0
    l[0] = 0

    while i < n+1:
        if l[i] == 0:
            a = -1
            for j in range(m,0,-1):
                if i+j < n+1 and l[i+j] != "1":
                    a = i+j
                    ans.append(j)
                    l[a] = 0
                    break
            if a == -1:
                print((-1))
                return
            else:
                i = a
            
            if l[-1] == 0:
                break
    
    print((*ans[::-1]))

def __starting_point():
    main()

__starting_point()

N,M = map(int ,input().split())
S = input()

ans = []
i = N
while i > 0:
    prev = i
    for j in range(max(0, i-M), i):
        if S[j] == "0":
            ans.append(str(i-j))
            i = j
            break
    if i == prev:
        ans = -1
        break

if ans == -1:
    print(ans)
else:
    ans.reverse()
    print(*ans)

import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    S = input()
    
    ans = []
    check = [False] * (N+1)
    
    idx = N
    while 0 < idx:
        f = False
        for i in range(M, 0, -1):
            if idx-i < 0: continue
            if S[idx-i] == '1':
                if check[idx-i]: print(-1); return
                else: check[idx-i] = True
            else:
                ans.append(i)
                idx -= i
                f = True
                break
        if not f: print(-1); return
    
    for a in ans[::-1]: print(a)
def __starting_point():
    main()
__starting_point()

import heapq


def main():
    N, M = list(map(int, input().split(' ')))
    S = input()
    # 最短手数のdpテーブルを作る
    T = S[::-1]  # ゴールから逆順にたどる（最後に逆にする）
    dp = [-1] * (N + 1)
    que = [0] * M
    for i, t in enumerate(T):
        if i == 0:
            dp[0] = 0
            continue
        if len(que) == 0:
            print((-1))
            return
        index = heapq.heappop(que)
        if t == '1':
            continue
        dp[i] = 1 + dp[index]
        while len(que) < M:
            heapq.heappush(que, i)
    dp.reverse()
    # 細切れに進んでいく
    path = list()
    target = dp[0] - 1
    cnt = 0
    for i in range(N + 1):
        if dp[i] != target:
            cnt += 1
        else:
            path.append(cnt)
            cnt = 1
            target -= 1
    print((' '.join(map(str, path))))


def __starting_point():
    main()

__starting_point()

from bisect import *
n, m = list(map(int, input().split()))
s = input()

masu = []
for i in range(n+1):
    if s[i] == "0":
        masu.append(i)

now = n
ans = [n]

while now > 0:
    next = masu[bisect_left(masu, now-m)]
    if now != next:
        ans.append(next)
        now = next
    else:
        ans = -1
        break

if ans == -1:
    print((-1))

else:
    ans.reverse()
    for i in range(len(ans)-1):
        print((ans[i+1]-ans[i]))


N, M = list(map(int, input().split()))
S = list(reversed(input()))

ans = []
cur = 0
while cur < N:
    for m in range(M, 0, -1):
        ncur = cur + m
        if ncur <= N and S[ncur] == '0':
            ans.append(m)
            cur = ncur
            break
    else:
        print((-1))
        return

print((*reversed(ans)))


n, m = map(int, input().split())
a = list(map(int, list(input())))
dp = [-1]*(n+1)
te = [-1]*(n+1)
te[n] = 0
g = [n]
c = 0
r = n
for i in reversed(range(n)):
  if a[i]:
    continue
  if i + m < r:
    r = i + m
    while a[r]:
      r -= 1
    if r == i:
      print(-1)
      return
  dp[i] = r
  te[i] = te[r] + 1
  if c < te[i]:
    c += 1
    g.append(i)
  g[te[i]] = i
g = g[::-1]
d = [y - x for x, y in zip(g,g[1:])]
print(*d)

import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり整数
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

N, M = list(map(int, input().split()))
S = input()


now = N
ans = []
while now > 0:
    for step in range(M, 0, -1):
        if now-step <0:
            step = now
        if S[now-step] == "0":
            ans.append(step)
            now -= step
            break
        if step == 1:
            print((-1))
            return

ans.reverse()
ret = ""
for a in ans:
    ret+= str(a) + " "

print(ret)




ii = lambda : int(input())
mi = lambda : list(map(int,input().split()))
li = lambda : list(map(int,input().split()))

n,m = mi()
s = input()

s = s[::-1]

ans = []
ima = 0
while ima != n:
    flag = False
    for i in range(m):
        tmp = m - i
        if ima + tmp > n:
            continue
        elif s[ima+tmp] ==str(1):
            continue
        else:
            ima += tmp
            ans.append(tmp)
            flag = True
            break
    if flag == False:
        print((-1))
        return  

print((*ans[::-1]))



n, m = list(map(int, input().split()))
s = input()

if "1" * m in s:
    print((-1))
    return

pos = n
ans = []
while pos > 0:
    prev = max(pos - m, 0)
    while s[prev] == "1":
        prev += 1

    ans.append(pos - prev)

    pos = prev

ans = ans[::-1]
print((*ans))


import sys
import heapq

def main():
  input = sys.stdin.readline
  n, m = map(int, input().split())
  s = input()
  
  inf = pow(10, 6)
  ans = [inf]*(n+1)
  key = []
  heapq.heapify(key)
  heapq.heappush(key, (0, n))
  ans[n] = 0
  index = n-1
  count = 0
  while key:
    sub = heapq.heappop(key)
    s1, s2 = sub[0], sub[1]
    if s1 < count:
      continue
    count = s1+1
    subindex = index
    for i in range(min([index, s2-1]), max([-1, s2-m-1]), -1):
      if ans[i] != inf:
        continue
      if s[i] == "1":
        continue
      heapq.heappush(key, (count, i))
      ans[i] = s2
      subindex = i
    index = subindex
    
  if ans[0] == inf:
    print(-1)
  else:
    index = 0
    answer = []
    while True:
      subindex = ans[index]
      answer.append(subindex-index)
      if subindex == n:
        break
      index = subindex
  
    print(*answer)
  
def __starting_point():
  main()
__starting_point()

n, m = map(int, input().split())
s = list(str(input()))
s = list(reversed(s))
#print(s)

ds = []
d = 1
for i in range(1, n+1):
    if s[i] == '0':
        ds.append(d)
        d = 1
    else:
        d += 1
#print(ds)

temp0 = 0
ans = []
for i in range(len(ds)):
    if ds[i] > m:
        print(-1)
        return
    temp1 = temp0 + ds[i]
    #print(temp1)
    if temp1 > m:
        ans.append(temp0)
        temp0 = ds[i]
    elif temp1 == m:
        ans.append(temp1)
        temp0 = 0
    else:
        temp0 = temp1
else:
    if temp0 != 0:
        ans.append(temp0)
ans = list(reversed(ans))
print(*ans)

def main():
    n,m=list(map(int,input().split()))
    s=input()
    
    route=[]
    i=n
    visited=n
    while True:
        if i-m<=0:
            route.append(i)
            break
        else:
            flag=False
            for j in range(i-m,visited):
                if flag:
                    break
                if s[j]=='0':
                    route.append(i-j)
                    visited=i-m
                    i=j
                    flag=True
            if flag:
                continue
            else:
                print((-1))
                return
    
    print((*route[::-1]))
def __starting_point():
    main()


__starting_point()

N,M=list(map(int,input().split()))
S=input()
S=S[::-1]
count=0
count_1=0
count_2=0
answer=[]
ans=0

for i,s in enumerate(S):
    #print(i)
    if i==0:
        pass
    elif i==N:
        count_1+=1
        answer.append(count_1)
        #print("g")
    elif s=="0"and count_1<M-1:
        count_1+=1
        count=count_1
        count_2=0
        #print("a")
    elif s=="0" and count_1==(M-1):
        count_1+=1
        count_2=0
        answer.append(count_1)
        count=0
        count_1=count
        #print("b")
    else:
        if count_1<M-1 and count_2<M-1:
            count_1+=1
            count_2+=1
            #print("c")
        elif count_2==M-1:
            ans=-1
            #print("d")
            break
        elif count_1==M-1:
            count_2+=1
            answer.append(count)
            count_1=count_2
            count=count_1
            #print("e")
if ans==-1:
    print((-1))
else:
    print((" ".join(map(str,answer[::-1]))))


# AtCoder Beginner Contest 146
# F - Sugoroku
# https://atcoder.jp/contests/abc146/tasks/abc146_f
import sys
N, M = list(map(int, input().split()))
*S, = list(map(int, input()))
S.reverse()

i = 0
ans = []
while i < N:
    for m in range(M, 0, -1):
        if i+m <= N and S[i+m] == 0:
            i += m
            ans += [m]
            break
    else:
        print((-1))
        return

print((*ans[::-1]))


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import deque

n, m = list(map(int, readline().split()))
s = readline().rstrip().decode()[::-1]
index = 0
ans = deque([])
for i in range(n):
    for j in range(m, 0, -1):
        if index + j >= n:
            ans.appendleft(n - index)
            print((*ans))
            return
        if s[index + j] == '0':
            ans.appendleft(j)
            index += j
            break
    else:
        print((-1))
        return


import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	N, M = MAP()
	S = input()

	pos_0 = []
	for i in range(N+1):
		if S[i] == "0":
			pos_0.append(i)

	q = deque([])
	pos = N
	while pos != 0:
		next_pos = pos-M
		idx = bisect_left(pos_0,next_pos)
		if pos-pos_0[idx] > M or pos == pos_0[idx]:  # 移動できない
			print((-1))
			return

		q.appendleft(pos-pos_0[idx])
		pos = pos_0[idx]

	print((*q))


def __starting_point():
	main()

__starting_point()

N, M = map(int, input().split())
S = input()
ans = []
tmp = S[::-1]
index = 0
acnt = M
while True:
    if acnt == 0:
        print(-1)
        return
    if index + acnt <= N and tmp[index + acnt] == '0':
        ans.append(acnt)
        index += acnt
        acnt = M
    else:
        acnt -= 1
    if index == N:
        break
print(*reversed(ans))

n,m=map(int,input().split())
s=input()[::-1]
ans=[]
now=0
while(now<n):
  t=1
  for i in reversed(range(1,m+1)):
    if now+i>n or s[now+i]=='1':
        continue
    now=now+i
    ans.append(i)
    t=0
    break
  if t:
    print(-1)
    return
ans.reverse()
print(*ans,sep=' ')