Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N, M = map(int, input().split())
from bisect import bisect_right
dic = [[] for i in range(N)]

shi = {}
for i in range(M):
    p, y = map(int, input().split())
    dic[p-1].insert(bisect_right(dic[p-1], y), y)
    shi[i] = (p, y)

for j in range(M):
    p, y = shi[j]
    print('{:06}{:06}'.format(p, bisect_right(dic[p-1], y)))



### FIXED CODE ###

N, M = map(int, input().split())
from bisect import bisect_right
dic = [[] for i in range(N)]

shi = {}
for i in range(M):
    p, y = map(int, input().split())
    dic[p-1].append(y)
    shi[i] = (p, y)

for i in range(N):
    dic[i].sort()

for j in range(M):
    p, y = shi[j]
    print('{:06}{:06}'.format(p, bisect_right(dic[p-1], y)))
### BUGGY CODE ###

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

ans = []
for _ in range(q):
    l,r = map(int,input().split())

    tmp_str = s[l-1:r]

    ans.append( tmp_str.count('AC') )

for i in ans:
    print(i)

### FIXED CODE ###

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

d= {}

for k in range(n):
    d[k]=0

total = 0
for j in range(n-1):
    if s[j]=='A' and s[j+1]=='C':
        total+=1
        d[j+1]+=total
    else:
        d[j+1]=total
        
# print(d)

ans = []
for _ in range(q):
    l,r = map(int,input().split())

    ans.append(d[r-1] -d[l-1])


for i in ans:
    print(i)
### BUGGY CODE ###

n = int(input())
ans = 0
for i in range(n-1):
    ans += (i+1)%(i+2)
print(ans)


### FIXED CODE ###

n = int(input())
print(((n-1)*n)//2)
### BUGGY CODE ###

def XOR(A, B):
    BA = bin(A)
    BA = int(BA[2:])
    BB = bin(B)
    BB = int(BB[2:])
    result = BA + BB
    result = str(result)
    result = result.replace('2', '0')
    result = int(result, 2)
    return result


L1 = input()
L2 = input()
L1 = L1.split()
L2 = L2.split()
for i, val in enumerate(L1):
    L1[i] = int(val)
for i, val in enumerate(L2):
    L2[i] = int(val)
maxInt = 0
sumInt = 0
for i in range(0, L1[1]+1, 1):
    for j in range(L1[0]):
        sumInt += XOR(i, L2[j])
    if sumInt > maxInt:
        maxInt = sumInt
    sumInt = 0
print(maxInt)

### FIXED CODE ###

def XOR(A, B):
    BA = int(A)
    BB = int(B)
    result = BA + BB
    result = str(result)
    result = result.replace('2', '0')
    result = int(result, 2)
    return result


L1 = input()
L2 = input()
L1 = L1.split()
L2 = L2.split()
for i, val in enumerate(L1):
    L1[i] = int(val)
K = L1[1]
K = bin(K)
K = K[2:]
lenK = len(K)
L3 = []
for i, val in enumerate(L2):
    L2[i] = int(val)
    L2[i] = bin(L2[i])
    lenL2i = len(L2[i])-2
    L2[i] = L2[i][2:]
    if lenL2i < lenK:
        dif = lenK - lenL2i
        for a in range(dif):
            L2[i] = '0' + L2[i]
        L3.append(L2[i])
    elif lenL2i == lenK:
        L3.append(L2[i])
    else:
        dif = lenL2i - lenK
        L3.append(L2[i][dif:])
final = ''
judgeFlag = 0
i = 0
finalJudge = 0
# print('K'+K)
if K == '0':
    final = '0'
else:
    while i < lenK:
        # print('roop'+str(i))
        # print(final)
        # print('judgeFlag' + str(judgeFlag))
        # print('finalJudge' + str(finalJudge))
        if (judgeFlag == 1) & (finalJudge == 0):
            if K[i] == '0':
                final += '0'
                i += 1
            else:
                # print(i)
                count_0 = 0
                count_1 = 0
                for each in L3:
                    if each[i] == '0':
                        count_1 += 1
                    else:
                        count_0 += 1
                if count_1 >= count_0:
                    final += '1'
                    judgeFlag = 1
                else:
                    final += '0'
                    finalJudge = 1
                i += 1
        else:
            # print(i)
            count_0 = 0
            count_1 = 0
            for each in L3:
                if each[i] == '0':
                    count_1 += 1
                else:
                    count_0 += 1
            if count_1 >= count_0:
                final += '1'
                judgeFlag = 1
            else:
                final += '0'
                finalJudge = 1
            i += 1
sumInt = 0
for each in L2:
    sumInt += XOR(final, each)
# print(final)
print(sumInt)
### BUGGY CODE ###

from functools import lru_cache


@lru_cache(maxsize=10 ** 5)
def factrial(n):
    ans = 1
    for i in range(1, n+1):
        ans *= i
    return ans


@lru_cache(maxsize=10 ** 5)
def combinations(n, r):
    return factrial(n) // (factrial(n - r) * factrial(r))


def main():
    n, k = map(int, input().split())
    A = sorted(map(int, input().split()))
    ans = 0
    mod = 10 ** 9 + 7
    for i, a in enumerate(A[k - 1:], k - 1):
        ans += ((a % mod) * (combinations(i, k - 1) % mod)) % mod
        ans %= mod
    for i, a in enumerate(A[: n - k + 1], 1):
        ans -= ((a % mod) * (combinations(n - i, k - 1)) % mod) % mod
        ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from functools import lru_cache
n, k = map(int, input().split())
A = sorted(map(int, input().split()))
mod = 10 ** 9 + 7
# 階乗とその逆元の計算
factrial = [0 for _ in range(n + 1)]
factrial[0] = 1
for i in range(1, n + 1):
    factrial[i] = (factrial[i - 1] * i) % mod
inverse_factrial = list()
for f in factrial:
    inverse_factrial.append(pow(f, -1, mod))


@lru_cache(maxsize=None)
def nCr(n, r):
    return (factrial[n] * inverse_factrial[r] * inverse_factrial[n - r]) % mod


ans = 0
# 最大値の和
for i, a in enumerate(A[k - 1:], k - 1):
    ans += ((a % mod) * nCr(i, k-1)) % mod
    ans %= mod
# 最小値の和
A.reverse()
for i, a in enumerate(A[k - 1:], k - 1):
    ans -= ((a % mod) * nCr(i, k-1)) % mod
    ans %= mod
print(ans)
### BUGGY CODE ###

from heapq import heappush, heappop

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

q = reads()
s = q[0] + q[1] * 1j
t = q[2] + q[3] * 1j

N = read()

p = []; r = []
for i in range(N):
  q = reads()
  p.append(q[0] + q[1] * 1j)
  r.append(q[2])

# Nがsource, N+1がtarget
E = [[0]*(N+2) for _ in range(N+2)]
for i in range(N):
  for j in range(N):
    E[i][j] = max(abs(p[i] - p[j]) - r[i] - r[j], 0)

for i in range(N):
  E[N][i]   = E[i][N]   = max(abs(p[i] - s) - r[i], 0)
  E[N+1][i] = E[i][N+1] = max(abs(p[i] - t) - r[i], 0)

E[N][N+1] = E[N+1][N] = abs(t - s)

INF = 10**15 * 1.0

dist = [INF] * (N+2)
que = [(0, N)]

while len(que) > 0:
  (d, u) = heappop(que)
  if dist[u] < d:
    continue
  for t in range(N+2):
    cost = E[u][t]
    if d + cost < dist[t]:
      dist[t] = d + cost
      heappush(que, (d + cost, t))

print(dist[N+1])


### FIXED CODE ###

from heapq import heappush, heappop

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

q = reads()
s = q[0] + q[1] * 1j
t = q[2] + q[3] * 1j

N = read()

p = []; r = []
for i in range(N):
  q = reads()
  p.append(q[0] + q[1] * 1j)
  r.append(q[2])

# Nがsource, N+1がtarget
E = [[0]*(N+2) for _ in range(N+2)]
for i in range(N):
  for j in range(N):
    E[i][j] = max(abs(p[i] - p[j]) - r[i] - r[j], 0)

for i in range(N):
  E[N][i]   = E[i][N]   = max(abs(p[i] - s) - r[i], 0)
  E[N+1][i] = E[i][N+1] = max(abs(p[i] - t) - r[i], 0)

E[N][N+1] = E[N+1][N] = abs(t - s)

INF = 10**15 * 1.0

dist = [E[N][i] for i in range(N+2)] + [INF]
stab = [False] * (N+2)

stab[N] = True

for _ in range(N+1):
  i = N+2
  for j in range(N+2):
    if not stab[j] and dist[j] < dist[i]:
      i = j
  stab[i] = True
  for j in range(N+2):
    dist[j] = min(dist[j], dist[i] + E[i][j])

print(dist[N+1])
### BUGGY CODE ###

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort(reverse = True)
    ans = 0
    for i in range(n):
        if a.count(a[i]) >= 4:
            ans = a[i]*a[i]
            break
        elif a.count(a[i]) >=2:
            for j in range(i+a.count(a[i]),n):
                if a.count(a[j]) >=2:
                    ans = a[i]*a[j]
                    break
            break
    print(ans)
main()

### FIXED CODE ###

n = int(input())
a=list(map(int,input().split()))

a.sort(reverse = True)
ans = 0
b = a.copy()
b = list(set(b))
b.sort(reverse = True)
c = [0]*len(b)
j = 0
c[j] = 1
for i in range(1,n):
    if a[i-1] == a[i]:
        c[j] +=1
    else:
        j+=1
        c[j] +=1
for i in range(len(b)):
    if c[i] >= 4:    
        
        ans = b[i]*b[i]
        break
    elif c[i] >= 2:
        for j in range(i+1,len(b)):
            if c[j] >= 2:
                ans = b[i]*b[j]
                break
        break
print(ans)
### BUGGY CODE ###

from heapq import heappush,heappop
n,q=map(int,input().split())
e=[]
for i in range(n):
  s,t,x=map(int,input().split())
  e.append([s-x,1,x])
  e.append([t-x,-1,x])
for i in range(q):
  d=int(input())
  e.append([d,2,0])
e.sort()
s=set()
a=[]
for time_,type_,x_ in e:
  if type_==1:
    s.add(x_)
    heappush(a,x_)
  elif type_==-1:
    s.remove(x_)
  else:
    while a and a[0] not in s:
      heappop(a)
    if a:
      print(a[0])
    else:
      print(-1)

### FIXED CODE ###

import sys
from heapq import heappush,heappop
input=sys.stdin.readline
n,q=map(int,input().split())
e=[]
for i in range(n):
  s,t,x=map(int,input().split())
  e.append((s-x,1,x))
  e.append((t-x,-1,x))
for i in range(q):
  d=int(input())
  e.append((d,2,0))
e.sort()
s=set()
a=[]
for time_,type_,x_ in e:
  if type_==1:
    s.add(x_)
    heappush(a,x_)
  elif type_==-1:
    s.remove(x_)
  else:
    while a and a[0] not in s:
      heappop(a)
    if a:
      print(a[0])
    else:
      print(-1)
### BUGGY CODE ###

from collections import namedtuple
Line = namedtuple('Line', ['lowest', 'end'])


def main():
    N = int(input())
    up_lines = []
    down_lines = []
    for i in range(N):
        s = input()
        now = 0
        lowest = 0
        for c in s:
            if c == "(":
                now += 1
            else:
                now -= 1
                lowest = min(lowest, now)
        if now > 0:
            up_lines.append(Line(lowest, now))
        else:
            down_lines.append(Line(lowest-now, -now))
    up_lines.sort(key=lambda line: -line.lowest)
    down_lines.sort(key=lambda line: -line.lowest)
    left = 0
    for line in up_lines:
        if left + line.lowest < 0:
            print("No")
            return
        left += line.end
        if left < 0:
            print("No")
            break
    right = 0
    for line in down_lines:
        if right + line.lowest < 0:
            print("No")
            return
        right += line.end
        if right < 0:
            print("No")
            break
    if left == right:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import namedtuple
Line = namedtuple('Line', ['lowest', 'end'])


def main():
    N = int(input())
    up_lines = []
    down_lines = []
    for i in range(N):
        s = input()
        now = 0
        lowest = 0
        for c in s:
            if c == "(":
                now += 1
            else:
                now -= 1
                lowest = min(lowest, now)
        if now > 0:
            up_lines.append(Line(lowest, now))
        else:
            down_lines.append(Line(lowest-now, -now))
    up_lines.sort(key=lambda line: -line.lowest)
    down_lines.sort(key=lambda line: -line.lowest)
    left = 0
    for line in up_lines:
        if left + line.lowest < 0:
            print("No")
            return
        left += line.end
        if left < 0:
            print("No")
            break
    right = 0
    for line in down_lines:
        if right + line.lowest < 0:
            print("No")
            return
        right += line.end
        if right < 0:
            print("No")
            break
    if left == right:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
### BUGGY CODE ###

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

import numpy as np

def canReach(src, dst):
    a = (dst[0] - src[0]) - np.sum(np.abs(src-dst)[1:3])
    if a >= 0 and a % 2 == 0:
        return True
    return False

N = int(input())
dst = np.array([[int(x) for x in input().split(" ")] for z in range(N)])

available = True
pos = [0, 0, 0]

for n in range(N):
    if not canReach(pos, dst[n]):
        available = False
        break
    else:
        pos = dst[n]

if available:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

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

import numpy as np

N = int(input())
prev_dst = [0,0,0]

for n in range(N):
    t, x, y = map(int, input().split(" "))
    a = (t - prev_dst[0]) - (np.abs(prev_dst[1]-x) + np.abs(prev_dst[2]-y))
    if a >= 0 and a % 2 == 0:
        prev_dst = [t, x, y]
    else:
        print("No")
        exit(0)

print("Yes")
### BUGGY CODE ###


a, b, n = map(int, input().split())

mx = 0

for i in range(n+1):
    if a*i//b-a*(i//b) > mx:
        mx = a*i//b-a*(i//b)
        
print(mx)
    

### FIXED CODE ###


a, b, n = map(int, input().split())

mx = 0

nn = n//b

mm = (a*n)//b - a*(nn)

if nn > 0:
    x = b*nn-1
    mx = (a*x)//b - a*(nn-1)
    mm = max(mm, mx)
    
print(mm)
### BUGGY CODE ###

n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
clis = [[x[1]]*x[0] for x in lis]
clis=(sum(clis,[]))
clis.sort(reverse=True)
alis.sort()
ans_lis=[x if x>=y else y for x,y in zip(alis,clis)]
if len(clis) < len(alis):
    ans__ = sum(alis[len(clis):])
    print(sum(ans_lis,ans__))
else:
    print(sum(ans_lis))


### FIXED CODE ###

n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
for x in alis:
    lis.append([1,x])
lis.sort(reverse=True,key=lambda x:x[1])
ans = 0
for x in lis:
    (number,point) = x
    if number >= n:
        number = n
        ans += number * point
        #print(n)
        #print(ans,'+=',number,'*',point)
        break
    ans += number * point
    n -= number
    #print(n)
    #print(ans,'+=',number,'*',point)
print(ans)
#print(lis)
### BUGGY CODE ###

import copy

s = str(input())
s_origin = copy.copy(s)

while len(s) > 0:
    if "10" in s:
        s = str(s).replace("10","")
    elif "01" in s:
        s = str(s).replace("01","")
    else:
        break

print(int(len(s_origin) - len(s)))

### FIXED CODE ###

s = str(input())

ct1 = s.count('1')
ct0 = s.count('0')

print(int(min(ct1,ct0)*2))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import numpy as np

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

l = []
r = []
for i in range(m):
    ll, rr = map(int, input().split())
    l.append(ll)
    r.append(rr)

ans = 0
t = [[0] * n for i in range(m)]

for i in range(m):
    for j in range(n):
        
        if l[i]<=j+1 and r[i]>=j+1:

            t[i][j] = 1

t_sum = np.sum(t, axis=0)

for i in range(n):
    if t_sum[i] == m:
        ans += 1

print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# import numpy as np

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

l_min = 1
r_max = n+1

for i in range(m):
    l, r = map(int, input().split())
    l_min = max(l_min, l)
    r_max = min(r_max, r)

ans = r_max - l_min + 1
if ans > 0:
    print(ans)
else:
    print(0)
### BUGGY CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')] * n

dp[0] = 0
for i in range(1, n):
  if i == 1:
    dp[i] = abs(h[i]-h[i-1])
  else:
    res = float('inf')
    for j in range(1, k+1):
      if i-j>=0:
        res = min(dp[i-j] + abs(h[i]-h[i-j]), res)
    dp[i] = res
    
print(dp[n-1])

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')] * n

dp[0] = 0
for i in range(1, n):
  dp[i] = min(dp[j]+abs(h[i]-h[j]) for j in range(max(0, i-k), i))

    
print(dp[n-1])
### BUGGY CODE ###

# ABC 055 B

N = int(input())
p = 1
for i in range(1, N+1):
    p *= i
print(p % 1000000007)

### FIXED CODE ###

# ABC 055 B

N = int(input())
p = 1
for i in range(1, N+1):
    p = p * i % 1000000007
print(p)
### BUGGY CODE ###

h, w, n = map(int, input().split())
a_list = [[0 for _ in range(w)] for _ in range(h)]
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    a_list[a][b] = 1
z_list = []
for center_x in range(1, h - 1):
    for center_y in range(1, w - 1):
        temp = a_list[center_x - 1: center_x + 2]
        temp_num = 0
        for ttt in temp:
            temp_num += sum(ttt[center_y - 1: center_y + 2])
        z_list.append(temp_num)
for i in range(10):
    print(z_list.count(i))

### FIXED CODE ###

from collections import Counter, defaultdict

ans = defaultdict(lambda: 0)
h, w, n = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for a_i in range(a - 2, a + 1):
        for b_i in range(b - 2, b + 1):
            if (0 <= a_i < h - 2) & (0 <= b_i < w - 2):
                ans[(a_i, b_i)] += 1

k = Counter(ans.values())
print((h - 2) * (w - 2) - sum(k.values()))
for i in range(1, 10):
    if i in k.keys():
        print(k[i])
    else:
        print(0)
### BUGGY CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))

e_p = []
for i in range(n):
    e_p.append(sum(range(1,p[i]+1)) / p[i])

max = 0
for i in range(n-k+1):
    if sum(e_p[i:i+k]) > max:
        max = sum(e_p[i:i+k])

print(max)


### FIXED CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)


ans = []
s = sum(e_p[:k])
ans.append(s)
for i in range(1,n-k+1):
    s -= e_p[i-1]
    s += e_p[i+k-1]
    ans.append(s)
print(max(ans))
### BUGGY CODE ###

import sys
import bisect
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(int, readline().split()))
    dp = [0] * 31
    for i in range(28, -1, -1):
        mdr = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= mdr
            a[j] %= mdr
        a.sort()
        b.sort()
        p1 = n
        p2 = n
        p3 = n
        for av in a:
            p3 = bisect.bisect_right(b, 3 * mdr // 2 - 1 - av, 0, p3)
            p2 = bisect.bisect_right(b, 2 * mdr // 2 - 1 - av, 0, p2)
            p1 = bisect.bisect_right(b, mdr // 2 - 1 - av, 0, p1)
            dp[i] += n - (p1 + p3 - p2)
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import bisect

readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
n = int(readline())
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))


def f(md):
    pos = n - 1
    res = 0
    for av in a:
        while True:
            if pos != -1 and av + b[pos] >= md:
                pos -= 1
            else:
                res += pos + 1
                break
    return res


def solve():
    dp = [0] * 31
    for i in range(28, -1, -1):
        md = pow(2, i + 1)
        for j in range(n-1, -1, -1):
            b[j] %= md
            a[j] %= md
        a.sort()
        b.sort()
        res1, res2, res3 = f(md // 2), f(md // 2 * 2), f(md // 2 * 3)
        dp[i] += (n - (res1 + res3 - res2)) % 2
    t = 0
    for i in range(31):
        t += pow(2, i) * (dp[i] % 2)
    print(t)


if __name__ == '__main__':
    solve()
### BUGGY CODE ###

n = int(input())
a_list = list(map(int,input().split()))
print_list = []
for i in range(1,n+1):
    print_list.append(a_list.index(i)+1)
for s in print_list:
  print(s, end =" ")

### FIXED CODE ###

# ABC 142 C go to school
n = int(input())
s = list(map(int,input().split()))

# ソートされたリストのインデックスを返す
s = sorted(range(len(s)), key=lambda k:s[k])
ans = [x+1 for x in s]
print(*ans)
### BUGGY CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug
from functools import lru_cache

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect

@lru_cache(maxsize=None)
def mutual_division_method(a, b):
    while not (a == 0 or b == 0):
        if a > b:
            a = a % b
        else:
            b = b % a
    if a == 0:
        return b
    else:
        return a

def mdm(a, b):
    if a < b:
        b, a = a, b
    return mutual_division_method(a, b)


def gcd(a, b, c):
    #print('a, b, c', a, b, c) # debug
    d = mdm(a, b)
    e = mdm(d, c)
    #print('e', e) # debug
    return e

if __name__ == '__main__':
    k = int(input())
    s = 0
    for a in range(1, k + 1):
        for b in range(1, k + 1):
            for c in range(1, k + 1):
                ans = gcd(a, b, c)
                s += ans
    #print('s') # debug
    print(s)

    #print('\33[32m' + 'end' + '\033[0m') # debug


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug
from functools import lru_cache

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect

def mutual_division_method(a, b):
    while not (a == 0 or b == 0):
        if a < b:
            b = b % a
        else:
            a = a % b
    if a == 0:
        return b
    else:
        return a



def gcd(a, b, c):
    #print('a, b, c', a, b, c) # debug
    d = mutual_division_method(a, b)
    e = mutual_division_method(d, c)
    #print('e', e) # debug
    return e

if __name__ == '__main__':
    k = int(input())
    s = 0
    for a in range(1, k + 1):
        for b in range(1, k + 1):
            for c in range(1, k + 1):
                ans = gcd(a, b, c)
                s += ans
    #print('s') # debug
    print(s)

    #print('\33[32m' + 'end' + '\033[0m') # debug
### BUGGY CODE ###

from collections import deque
INF = 10**18

def append_dq(i, x, dq, dp1):
    while True:
        if not len(dq):
            dq.append(i)
            break
        lxi = dq[-1]
        if x > dp1[lxi]:
            dq.append(i)
            break
        dq.pop()
    return dq

dq = deque()
N,M = map(int, input().split())
S = input().strip()
dp1 = [0] + [INF]*N
dp2 = [[] for _ in range(N+1)]
dq.append(0)

for i, c in enumerate(S[1:]):
    i+=1
    dq = append_dq(i, dp1[i], dq, dp1)
    if c == "1":
        if i >= M:
            sxi = dq[0]
            if sxi == (i - M):
                dq.popleft()
        continue
    idx = dq[0]
    if dp1[idx] == INF:
        if i >= M:
            sxi = dq[0]
            if sxi == (i - M):
                dq.popleft()
        continue
    dp1[i] = dp1[idx] + 1
    dp2[i] = dp2[idx] + [i-idx]
    if i >= M:
        sxi = dq[0]
        if sxi == (i - M):
            dq.popleft()
if dp1[-1] == INF:
    print(-1)
else:
    print(" ".join(map(str, dp2[-1])))


### FIXED CODE ###

from collections import deque
INF = 10**18

def append_dq(i, x, dq, dp1):
    while True:
        if not len(dq):
            dq.append(i)
            break
        lxi = dq[-1]
        if x > dp1[lxi]:
            dq.append(i)
            break
        dq.pop()
    return dq
dq = deque()
N,M = map(int, input().split())
S = input().strip()
dp1 = [0] + [INF]*N
dp2 = [-1 for _ in range(N+1)]
dq.append(0)
for i, c in enumerate(S[1:]):
    i+=1
    dq = append_dq(i, dp1[i], dq, dp1)
    idx = dq[0]
    if c != "1" and dp1[idx] != INF:
        dp1[i] = dp1[idx] + 1
        dp2[i] = idx
    if i >= M:
        sxi = dq[0]
        if sxi == (i - M):
            dq.popleft()
if dp1[-1] == INF:
    print(-1)
else:
    r = []
    s = N
    while True:
        if s == 0:
            break
        ns = dp2[s]
        r.append(s-ns)
        s = ns
    print(" ".join(map(str, r[::-1])))