You are given a binary string of length $n$ (i. e. a string consisting of $n$ characters '0' and '1').

In one move you can swap two adjacent characters of the string. What is the lexicographically minimum possible string you can obtain from the given one if you can perform no more than $k$ moves? It is possible that you do not perform any moves at all.

Note that you can swap the same pair of adjacent characters with indices $i$ and $i+1$ arbitrary (possibly, zero) number of times. Each such swap is considered a separate move.

You have to answer $q$ independent test cases.


-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 10^4$) — the number of test cases.

The first line of the test case contains two integers $n$ and $k$ ($1 \le n \le 10^6, 1 \le k \le n^2$) — the length of the string and the number of moves you can perform.

The second line of the test case contains one string consisting of $n$ characters '0' and '1'.

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^6$ ($\sum n \le 10^6$).


-----Output-----

For each test case, print the answer on it: the lexicographically minimum possible string of length $n$ you can obtain from the given one if you can perform no more than $k$ moves.


-----Example-----
Input
3
8 5
11011010
7 9
1111100
7 11
1111100

Output
01011110
0101111
0011111



-----Note-----

In the first example, you can change the string as follows: $1\underline{10}11010 \rightarrow \underline{10}111010 \rightarrow 0111\underline{10}10 \rightarrow 011\underline{10}110 \rightarrow 01\underline{10}1110 \rightarrow 01011110$. 

In the third example, there are enough operations to make the string sorted.

Source: codeforces | Difficulty: MEDIUM
Tags: Greedy algorithms


Solutions:
t = int(input())
for T in range(t):
	(n, k) = [int(x) for x in input().split()]
	s = list(input())
	l = ['1'] * n
	ind = 0
	for i in range(n):
		if s[i] == '0':
			val = min(k, i - ind)
			k -= val
			l[i - val] = '0'
			ind += 1
	print(''.join(l))


t = int(input())
for test in range(t):
	(n, k) = [int(x) for x in input().split()]
	s = list(input())
	zer = []
	for i in range(n):
		if s[i] == '0':
			zer.append(i)
	curr = 0
	while k > 0 and curr < len(zer):
		if curr == 0:
			swaps = zer[curr]
		else:
			swaps = zer[curr] - zer[curr - 1] - 1
		if swaps > k:
			swaps = k
		if swaps == 0:
			curr += 1
			continue
		x = zer[curr]
		y = x - swaps
		s[x] = '1'
		s[y] = '0'
		k = k - swaps
		zer[curr] = y
		curr += 1
	for i in range(n):
		print(s[i], end='')
	print()


t = int(input())
while t:
	s = input().split(' ')
	n = int(s[0])
	k = int(s[1])
	s = input()
	v = [-1]
	ans = []
	for i in range(n):
		ans.append(1)
		if s[i] == '0':
			v.append(i)
	l = len(v)
	for i in range(1, l):
		now = max(v[i - 1] + 1, v[i] - k)
		k -= v[i] - now
		v[i] = now
		ans[v[i]] = 0
	for i in range(n):
		if ans[i] > 0:
			print('1', end='')
		else:
			print('0', end='')
	print('')
	t -= 1


T = int(input())
while T != 0:
	T = T - 1
	(n, k) = (int(x) for x in input().split())
	num = input()
	cnt = 0
	res = ''
	for i in range(n):
		if num[i] == '0':
			if cnt <= k:
				k = k - cnt
				res += '0'
			else:
				res = res + '1' * (cnt - k)
				res = res + '0'
				res = res + '1' * k
				res = res + num[i + 1:]
				break
		else:
			cnt += 1
	if len(res) != n:
		res = res + '1' * cnt
	print(res)


import math
t = int(input())
for _ in range(0, t):
	info = list(map(int, input().split()))
	l = info[0]
	m = info[1]
	numbers = list(input())
	result = ['1'] * l
	b = 0
	for d in range(l):
		if numbers[d] == '0':
			moves_to_go = min(m, d - b)
			m = m - moves_to_go
			result[d - moves_to_go] = '0'
			b += 1
	print(''.join(result))


q = int(input())
for _ in range(q):
	(n, k) = [int(x) for x in input().split()]
	a = input()
	res = ['1'] * n
	t = 0
	for i in range(len(a)):
		if a[i] == '0':
			x = min(k, i - t)
			k -= x
			res[i - x] = '0'
			t += 1
	print(''.join(res))


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	a = list(stdin.readline().rstrip())
	if '1' not in a:
		print(''.join(a))
		continue
	cnt = 0
	pos = a.index('1')
	for i in range(pos, n):
		c = a[i]
		if c == '1':
			cnt += 1
		else:
			need = i - pos
			if need <= k:
				(a[pos], a[i]) = ('0', '1')
				pos += 1
				k -= need
			elif k:
				(a[i - k], a[i]) = ('0', '1')
				k = 0
		if not k:
			break
	print(''.join(a))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(input())
	an = ['1'] * n
	t = 0
	for j in range(n):
		if arr[j] == '0':
			s = min(k, j - t)
			k -= s
			an[j - s] = '0'
			t += 1
	print(''.join(an))


import bisect
q = int(input())
for _ in range(q):
	(n, k) = list(map(int, input().split()))
	s = input()
	ans = []
	for i in range(n):
		if s[i] == '0':
			ans.append(i)
	cnt = 0
	for (i, pos) in enumerate(ans):
		if cnt + pos - i <= k:
			cnt += pos - i
		else:
			res = list('0' * i + '1' * (pos - i) + s[pos:])
			res[pos] = '1'
			res[pos - (k - cnt)] = '0'
			print(''.join(res))
			break
	else:
		print('0' * len(ans) + '1' * (n - len(ans)))


N = int(input())
for _ in range(N):
	(n, k) = map(int, input().split())
	a = [int(i) for i in input()]
	Z = []
	for (i, v) in enumerate(a):
		if v == 0:
			Z.append(i)
	s = 0
	rem = k
	for z in Z:
		if not rem:
			break
		if s == z:
			s += 1
			continue
		mv = min(z - s, rem)
		a[z - mv] = 0
		a[z] = 1
		s += 1
		rem -= mv
	print(''.join(map(str, a)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	m = 0
	while m < n and s[m] is '0':
		m += 1
	if m == n:
		print(s)
		continue
	c = 1
	while m + c < n and k > 0:
		if s[m + c] is '1':
			c += 1
		else:
			m += 1
			k -= c
	if k >= 0:
		print('0' * m + '1' * c + s[m + c:])
	else:
		print('0' * (m - 1) + '1' * -k + '0' + '1' * (c + k) + s[m + c:])


def minimization(n, m, s):
	result = ['1'] * n
	last_zero = 0
	for i in range(n):
		if s[i] == '0':
			x = min(m, i - last_zero)
			result[i - x] = '0'
			m -= x
			last_zero += 1
	return ''.join(result)
for _ in range(int(input())):
	(N, M) = [int(j) for j in input().split()]
	t = input()
	print(minimization(N, M, t))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = [sym for sym in input()]
	start = 0
	for (ind, zero_or_one) in enumerate(s):
		if zero_or_one == '0' and ind == start:
			start += 1
		elif zero_or_one == '0':
			if k >= ind - start:
				k -= ind - start
				(s[start], s[ind]) = ('0', '1')
			elif k != 0:
				(s[ind - k], s[ind]) = ('0', '1')
				k = 0
			start += 1
	print(''.join((str(i) for i in s)))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	anss = ['1'] * n
	t = 0
	for j in range(n):
		if a[j] == '0':
			s = min(k, j - t)
			k -= s
			anss[j - s] = '0'
			t += 1
	print(''.join(anss))


n = int(input())
for i in range(n):
	asdf = [int(x) for x in input().split(' ')]
	bi = list(input())
	l = asdf[0]
	k = asdf[1]
	onesStart = 0
	ci = 0
	while k > 0 and ci < l:
		if bi[ci] == '0':
			if k < ci - onesStart:
				onesStart = ci - k
				k = 0
			else:
				k -= ci - onesStart
			temp = bi[ci]
			bi[ci] = bi[onesStart]
			bi[onesStart] = temp
			onesStart += 1
		ci += 1
	print(''.join(bi))


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	lst = input()
	loc = []
	for j in range(n):
		if lst[j] == '0':
			loc.append(j)
	sort_ct = 0
	move_ct = 0
	last_index = 0
	last_curr_loc = 0
	flag = 0
	for curr_loc in loc:
		if move_ct + curr_loc - sort_ct <= k:
			move_ct += curr_loc - sort_ct
			sort_ct += 1
			last_index = sort_ct - 1
			last_curr_loc = curr_loc
			flag = 1
		else:
			last_index = curr_loc - (k - move_ct)
			last_curr_loc = curr_loc
			flag = 0
			break
	ans = '0' * sort_ct
	ans += '1' * (last_index - sort_ct)
	if not flag:
		ans += '0'
	ans += '1' * (last_curr_loc - last_index)
	ans += lst[last_curr_loc + 1:]
	if '0' not in lst:
		ans = '1' * n
	elif '1' not in lst:
		ans = '0' * n
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	(item, res, case) = (0, '', 0)
	for (i, x) in enumerate(s):
		if x == '1':
			if case == 0:
				ind = i
			item += 1
		elif k >= item:
			k -= item
		else:
			if k == 0:
				elem = 1
			else:
				elem = item - k
			res += (i - item) * '0' + (item - k) * '1' + '0' + k * '1' + s[i + 1:]
			print(res)
			break
	if res == '':
		print('0' * (n - item) + '1' * item)


q = int(input())
for qi in range(q):
	(n, k) = map(int, input().split())
	s = input()
	number_of_ones = 0
	number_of_leading_zeroes = 0
	i = 0
	while i < len(s) and s[i] == '0':
		number_of_leading_zeroes += 1
		i += 1
	for i in range(number_of_leading_zeroes, n):
		if s[i] == '1':
			number_of_ones += 1
		elif k > number_of_ones:
			number_of_leading_zeroes += 1
			k -= number_of_ones
		elif k <= number_of_ones:
			print('0' * number_of_leading_zeroes, end='')
			print('1' * (number_of_ones - k), end='')
			print('0', end='')
			print('1' * k, end='')
			print(s[i + 1:])
			k = 0
			break
	if k > 0:
		for letter in sorted(s):
			print(letter, end='')
		print()


import sys

def I():
	return sys.stdin.readline().rstrip()
q = int(I())
for _ in range(q):
	(n, k) = list(map(int, I().split()))
	l = I()
	r = []
	o = 0
	for i in l:
		if i == '1':
			o += 1
		else:
			t = max(0, o - k)
			r.extend(['1'] * t)
			o -= t
			k -= o
			r.append('0')
	r.extend(['1'] * o)
	print(''.join(r))


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = input().strip()
	a = []
	for i in range(len(s)):
		if s[i] == '0':
			a.append(i)
	z = 0
	d = dict()
	for i in range(len(a)):
		if k >= a[i] - z:
			k -= a[i] - z
			a[i] = z
			d[z] = a[i]
			z += 1
		elif k > 0:
			d[a[i] - k] = a[i] - k
			a[i] -= k
			k = 0
		else:
			d[a[i]] = a[i]
	ans = ''
	z = 0
	for i in range(len(s)):
		if i in d:
			print('0', end='')
		else:
			print('1', end='')
	print()


q = int(input())
for p in range(q):
	(n, k) = list((int(j) for j in input().split()))
	b = input()
	A = list(b)
	i = 0
	pos = -1
	while i < n and k > 0:
		if pos < 0 and A[i] == '1':
			pos = i
		elif A[i] == '0' and pos >= 0:
			jump = i - pos
			if jump <= k:
				(A[i], A[pos]) = (A[pos], A[i])
				k -= jump
				pos += 1
			else:
				(A[i], A[i - k]) = (A[i - k], A[i])
				k = 0
		i += 1
	A = ''.join(A)
	print(A)


def swap(s, i, j):
	(s[i], s[j]) = (s[j], s[i])
Q = int(input())
for q in range(Q):
	(n, k) = map(int, input().split())
	bs = list(input())
	i = 0
	while i < n and bs[i] == '0':
		i += 1
	if i == n:
		print(''.join(bs))
		continue
	left_most_one = i
	while True:
		while i < n and bs[i] == '1':
			i += 1
		if i == n:
			print(''.join(bs))
			break
		if i - left_most_one <= k:
			swap(bs, left_most_one, i)
			k -= i - left_most_one
			left_most_one += 1
		elif k > 0:
			swap(bs, i - k, i)
			print(''.join(bs))
			break
		else:
			print(''.join(bs))
			break


def solve():
	q = int(input())
	for _ in range(q):
		(n, k) = map(int, input().split())
		s = input()
		z = 0
		d = ['1'] * n
		for i in range(n):
			if s[i] == '0':
				if k >= i - z:
					k -= i - z
					d[z] = '0'
					z += 1
				elif k > 0:
					d[i - k] = '0'
					k = 0
				else:
					d[i] = '0'
		print(''.join(d))
solve()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	count = z = 0
	for i in range(n):
		c = s[i]
		if c == '1':
			count += 1
			continue
		if count < k:
			z += 1
			k -= count
		else:
			print('0' * z, end='')
			print((count - k) * '1' + '0', end='')
			break
	else:
		print('0' * z, end='')
		k = count
	print('1' * k + s[i + 1:])


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s = input()
	ans = list('1' * n)
	last_zero = 0
	for i in range(n):
		if s[i] == '0':
			x = min(m, i - last_zero)
			ans[i - x] = '0'
			m -= x
			last_zero += 1
	print(''.join(ans))


from sys import *
from math import *
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	a = list(map(int, input()))
	b = [1] * n
	j = 0
	for i in range(n):
		if a[i] == 0:
			if i - j <= k:
				k -= i - j
				b[j] = 0
				j += 1
			elif b[i - k] != 0 or k == 0:
				b[i - k] = 0
				k = 0
			else:
				b[i - k + 1] = 0
				k = 0
	print(*b, sep='')


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	li = list(input())
	ones = 0
	for i in range(0, n):
		if li[i] == '1':
			ones = ones + 1
		else:
			li[i] = '1'
			m = min(k, ones)
			li[i - m] = '0'
			k = k - m
			if k == 0:
				break
	print(''.join(li))


class Case:

	def __init__(self, size, moves, string):
		self.size = size
		self.moves = moves
		self.string = string
SPACE = ' '
ZERO = '0'

def get_case():
	line_elements = input().split(SPACE)
	size = int(line_elements[0])
	moves = int(line_elements[1])
	string = list(input())
	return Case(size, moves, string)

def swap(index, next_zero_index, string):
	(string[index], string[next_zero_index]) = (string[next_zero_index], string[index])
	return string

def solve(case):
	next_zero_index = 0
	remaining_moves = case.moves
	string = case.string
	for index in range(case.size):
		if remaining_moves == 0:
			break
		current_char = string[index]
		if index == 0:
			if current_char == ZERO:
				next_zero_index += 1
			continue
		previous_char = string[index - 1]
		need_to_move = current_char == ZERO and previous_char != ZERO
		if need_to_move:
			desired_moves = index - next_zero_index
			allowed_moves = min(remaining_moves, desired_moves)
			target_index = next_zero_index + abs(desired_moves - allowed_moves)
			string = swap(index, target_index, string)
			remaining_moves -= allowed_moves
			next_zero_index += 1
		elif current_char == ZERO:
			next_zero_index += 1
	return string
number_of_cases = int(input())
for i in range(number_of_cases):
	case = get_case()
	solvedList = solve(case)
	solution = ''.join(solvedList)
	print(solution)


q = int(input().strip())
for _ in range(q):
	(n, k) = map(int, input().strip().split())
	s = input().strip()
	s = [i for i in s]
	z_has = 0
	for i in range(len(s)):
		if s[i] == '0':
			if k - (i - z_has) >= 0:
				k -= i - z_has
				temp = s[i]
				s[i] = s[z_has]
				s[z_has] = temp
				z_has += 1
			else:
				temp = s[i]
				s[i] = s[i - k]
				s[i - k] = temp
				break
	print(''.join(s))


q = int(input())
for _ in q * ' ':
	(n, k) = map(int, input().split())
	s = list(input())
	i = 0
	t = k
	c = 0
	while i < n and s[i] == '0':
		i += 1
		c += 1
	while i < n and k > 0:
		if s[i] == '0':
			u = min(i - c, k)
			k -= u
			(s[i], s[i - u]) = (s[i - u], s[i])
			c += 1
		i += 1
	print(*s, sep='')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	(n, k) = sep()
	a = list(inp())
	for i in range(n):
		a[i] = int(a[i])
	if a.count(1) == 0:
		print(''.join((str(a[i]) for i in range(len(a)))))
		return
	ind = a.index(1)
	for i in range(ind + 1, n):
		if a[i] == 0:
			if k >= i - ind:
				(a[ind], a[i]) = (a[i], a[ind])
				k -= i - ind
				ind += 1
			else:
				(a[i - k], a[i]) = (a[i], a[i - k])
				break
	print(''.join((str(a[i]) for i in range(len(a)))))
testcase(int(inp()))


t = int(input())
while t > 0:
	t = t - 1
	w = input()
	w = w.split()
	n = int(w[0])
	k = int(w[1])
	s = input()
	zero = 0
	one = 0
	for i in range(0, len(s)):
		if s[i] == '1':
			one = one + 1
		elif k >= one:
			k = k - one
			print('0', end='')
		else:
			for j in range(0, one - k):
				print(1, end='')
			print('0', end='')
			for j in range(one - k, one):
				print('1', end='')
			for j in range(i + 1, len(s)):
				print(s[j], end='')
			one = 0
			break
	for i in range(0, one):
		print('1', end='')
	print()


class Case:

	def __init__(self, size, moves, string):
		self.size = size
		self.moves = moves
		self.string = string
SPACE = ' '
ZERO = '0'

def getCase():
	lineElements = input().split(SPACE)
	size = int(lineElements[0])
	moves = int(lineElements[1])
	string = list(input())
	return Case(size, moves, string)

def getAllowedMoves(remainingMoves, desiredMoves):
	hasEnoughMoves = remainingMoves - desiredMoves >= 0
	return desiredMoves if hasEnoughMoves else remainingMoves

def move(index, allowedMoves, string):
	targetIndex = index - allowedMoves
	return string[:targetIndex] + string[index] + string[targetIndex:index] + string[index + 1:]

def swap(index, nextZeroIndex, string):
	(string[index], string[nextZeroIndex]) = (string[nextZeroIndex], string[index])
	return string

def solve(case):
	nextZeroIndex = 0
	remainingMoves = case.moves
	string = case.string
	for index in range(case.size):
		if remainingMoves == 0:
			break
		char = string[index]
		if index == 0:
			if char == ZERO:
				nextZeroIndex += 1
			continue
		previousChar = string[index - 1]
		needToMove = char == ZERO and previousChar != ZERO
		if needToMove:
			desiredMoves = index - nextZeroIndex
			allowedMoves = getAllowedMoves(remainingMoves, desiredMoves)
			targetIndex = nextZeroIndex + abs(desiredMoves - allowedMoves)
			string = swap(index, targetIndex, string)
			remainingMoves -= allowedMoves
			nextZeroIndex += 1
		elif char == ZERO:
			nextZeroIndex += 1
	return string
number_of_cases = int(input())
for i in range(number_of_cases):
	case = getCase()
	solvedList = solve(case)
	solution = ''.join(solvedList)
	print(solution)


Q = int(input())
result = []
for q in range(Q):
	(n, k) = map(int, input().split())
	arr = list(input())
	numOnes = 0
	succs = 0
	broke = False
	for i in range(n):
		if arr[i] == '0':
			if k >= numOnes:
				k -= numOnes
				succs += 1
			else:
				broke = True
				break
		else:
			numOnes += 1
	if not broke:
		result.append('0' * (n - numOnes) + '1' * numOnes)
	else:
		skipZeroes = succs + 1
		skipOnes = numOnes - k
		out = ['0'] * succs + ['1'] * skipOnes + ['0']
		for i in range(n):
			if arr[i] == '0':
				if skipZeroes > 0:
					skipZeroes -= 1
				else:
					out.append('0')
			elif skipOnes > 0:
				skipOnes -= 1
			else:
				out.append('1')
		result.append(''.join(out))
for i in result:
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, list(input())))
	l = 0
	r = 0
	c = 0
	while r < n and k > 0:
		if a[r] == 1:
			c += 1
		if a[r] == 0:
			x = min(c, k)
			(a[r - x], a[r]) = (a[r], a[r - x])
			k -= x
		r += 1
	print(''.join(map(str, a)))


import sys
for q in range(int(sys.stdin.readline())):
	(n, k) = [int(j) for j in sys.stdin.readline().split()]
	d = [int(j) for j in sys.stdin.readline().strip()]
	ind = []
	for i in range(n):
		if not d[i]:
			ind.append(i)
	h = len(ind)
	for i in range(h):
		mov = min(ind[i] - i, k)
		k -= mov
		v = d[ind[i] - mov]
		d[ind[i] - mov] = 0
		d[ind[i]] = v
		if k == 0:
			break
	sys.stdout.write(''.join(map(str, d)) + '\n')


from sys import stdin
input = stdin.readline

def solve(s, k):
	result = []
	ones = 0
	for char in s:
		if k == 0:
			break
		elif char == 1:
			ones += 1
		elif k >= ones:
			result.append(0)
			k -= ones
		elif k > 0:
			result += [1] * (ones - k)
			result.append(0)
			result += [1] * k
			ones = 0
			break
	result += [1] * ones
	result += s[len(result):]
	result = ''.join(map(str, result))
	return result
for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = [int(x) for x in input().strip()]
	print(solve(s, k))


q = int(input())
while q:
	(n, k) = list(map(int, input().split()))
	str_ = list(input())
	cur = 0
	for i in range(n):
		if str_[i] == '0':
			if i - cur <= k:
				tmp = str_[cur]
				str_[cur] = str_[i]
				str_[i] = tmp
				k = k - (i - cur)
				cur += 1
			else:
				tmp = str_[i - k]
				str_[i - k] = str_[i]
				str_[i] = tmp
				break
	print(''.join(str_))
	q -= 1


q = int(input())
for __ in [0] * q:
	(n, k) = list(map(int, input().split()))
	a = list(input())
	q = k
	p = -1
	res = []
	for i in range(n):
		if p == -1 and a[i] == '1':
			p = i
			res.append('1')
		elif p != -1 and a[i] == '0':
			if q >= i - p:
				res[p] = '0'
				res.append('1')
				q -= i - p
				p += 1
			elif q != 0:
				res[i - q] = '0'
				res.append('1')
				q = 0
			else:
				res.append('0')
		else:
			res.append(a[i])
	ans = ''.join(res)
	print(ans)


tests = int(input())
for _ in range(tests):
	(length, nb_switches) = list(map(int, input().split()))
	zeros_positions = {}
	nb_zeros = 0
	the_string = list(input())
	for (i, x) in enumerate(the_string):
		if x == '0':
			nb_zeros += 1
			zeros_positions[nb_zeros] = i
	if nb_switches >= length ** 2:
		sol = ['0'] * nb_zeros + ['1'] * (length - nb_zeros)
		print(''.join(sol))
		continue
	perfect = True
	for i in range(1, nb_zeros + 1):
		if nb_switches >= zeros_positions[i] - i + 1:
			nb_switches -= zeros_positions[i] - i + 1
		elif nb_switches <= zeros_positions[i] - i + 1:
			perfect = False
			last_z_final_pos = zeros_positions[i] - nb_switches
			last_z_initial_pos = zeros_positions[i]
			zeros_pos_correctly = i - 1
			break
	if perfect:
		sol = ['0'] * nb_zeros + ['1'] * (length - nb_zeros)
		print(''.join(sol))
	else:
		sol = ['0'] * zeros_pos_correctly + ['1'] * (last_z_final_pos - zeros_pos_correctly) + ['0'] + ['1'] * (last_z_initial_pos - last_z_final_pos) + the_string[last_z_initial_pos + 1:]
		print(''.join(sol))


from bisect import bisect_left
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	ind = []
	s = 0
	zero = a.count('0')
	for i in range(n):
		if a[i] == '0':
			ind.append(i)
	for i in range(zero):
		s += ind[i] - i
	if s <= k:
		print('0' * zero + '1' * (n - zero))
	else:
		p = ['1'] * n
		ans = []
		start = 0
		for i in range(zero):
			if ind[i] - k <= 0:
				ans.append(start)
				k = max(0, k - (ind[i] - start))
				start += 1
			elif ind[i] - k > 0:
				if ind[i] - k > start:
					ans.append(ind[i] - k)
					k = 0
				else:
					ans.append(start)
					k = max(0, k - (ind[i] - start))
					start += 1
		for i in range(zero):
			p[ans[i]] = '0'
		print(*p, sep='')


import sys

def main():
	for _ in range(int(input())):
		(n, k) = get_ints()
		s = list(input())
		x = []
		for i in range(n):
			if s[i] == '0':
				x.append((i, i - len(x)))
		i = 0
		while k > 0 and i < len(x):
			if x[i][1] < k:
				(s[i], s[x[i][0]]) = (s[x[i][0]], s[i])
				k -= x[i][1]
				i += 1
			else:
				(s[x[i][0] - k], s[x[i][0]]) = (s[x[i][0]], s[x[i][0] - k])
				break
		print(*s, sep='')
input = lambda : sys.stdin.readline().strip()
get_ints = lambda : map(int, input().split())
get_array = lambda : list(map(int, input().split()))
main()


def minimize_binary(n, k, s):
	s = list(s)
	putzerohere = 0
	for i in range(n):
		if s[i] == '0':
			if i - putzerohere <= k:
				k -= i - putzerohere
				(s[i], s[putzerohere]) = (s[putzerohere], s[i])
				putzerohere += 1
			else:
				(s[i], s[i - k]) = (s[i - k], s[i])
				break
	return ''.join(s)

def solve():
	q = int(input())
	for _ in range(q):
		(n, k) = map(int, input().split())
		s = input()
		print(minimize_binary(n, k, s))
solve()


T = int(input())
while T > 0:
	(n, k) = map(int, input().split())
	arr = input()
	as_list = list(arr)
	index = 0
	for i in range(n):
		if arr[i] == '0':
			steps = i - index
			if steps <= k:
				if steps > 0:
					as_list[index] = '0'
					as_list[i] = '1'
				k -= steps
				index += 1
			else:
				as_list[i] = '1'
				as_list[i - k] = '0'
				break
	print(''.join(as_list))
	T -= 1


t = int(input())
for ii in range(t):
	(n, k) = list(map(int, input().split()))
	s = input()
	zeroPos = []
	oneFound = -1
	for i in range(len(s)):
		if s[i] == '0':
			if oneFound >= 0:
				zeroPos.append(i)
		elif oneFound < 0:
			oneFound = i
	if oneFound == -1 or len(zeroPos) == 0:
		print(s)
	else:
		i = 0
		while i < len(zeroPos) and zeroPos[i] - i - oneFound < k:
			k -= zeroPos[i] - i - oneFound
			i += 1
		ans = '0' * (oneFound + i)
		if i < len(zeroPos):
			ans += '1' * (zeroPos[i] - k - oneFound - i)
			ans += '0'
			ans += '1' * k
			if zeroPos[i] + 1 < len(s):
				ans += s[zeroPos[i] + 1:]
		else:
			ans += '1' * (len(s) - oneFound - i)
		print(ans)


from collections import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
q = ri()
for _ in range(q):
	(n, k) = rl()
	s = input()
	cnt = 0
	zeros = 0
	test = False
	for i in range(n):
		if s[i] == '1':
			cnt += 1
		elif cnt <= k:
			zeros += 1
			k -= cnt
		else:
			test = True
			ans = '0' * zeros + '1' * (cnt - k) + '0' + '1' * k + s[i + 1:]
			break
	if not test:
		ans = '0' * zeros + '1' * cnt
	print(ans)


n = int(input())
for _ in range(n):
	(n, k) = list(map(int, input().split()))
	s = input()
	r = []
	j = 0
	p = False
	for i in range(n):
		if s[i] == '0':
			if j <= k:
				r.append('0')
				k -= j
			else:
				for x in range(j - k):
					r.append('1')
				r.append('0')
				for x in range(k):
					r.append('1')
				r.append(s[i + 1:])
				p = True
				print(''.join(r))
				break
		else:
			j += 1
	if not p:
		for x in range(j):
			r.append('1')
		print(''.join(r))


t = int(input())
while t > 0:
	l1 = list(map(int, input().split()))
	n = l1[0]
	m = l1[1]
	l = list(map(int, input()))
	i = 0
	j = 0
	while m > 0 and i < n:
		if l[i] == 0:
			t1 = i - j
			m -= t1
			j += 1
			if m >= 0:
				l[i] = 1
				l[j - 1] = 0
			else:
				l[i] = 1
				l[j - m - 1] = 0
				break
		i += 1
	for i in range(0, n - 1):
		print(l[i], end='')
	print(l[n - 1])
	t -= 1


def get_min_swapped(s, k):
	s = list(s)
	if '1' in s:
		b_idx = s.index('1')
	else:
		return ''.join(s)
	for (i, c) in enumerate(s):
		if i > b_idx:
			if c == '0':
				swp_idx = max(b_idx, i - k)
				s[swp_idx] = '0'
				s[i] = '1'
				k -= i - swp_idx
				b_idx = swp_idx + 1
				if k == 0:
					break
	return ''.join(s)
for _ in range(int(input())):
	(_, k) = map(int, input().split())
	print(get_min_swapped(input(), k))


amount = int(input())
for i in range(amount):
	(n, k) = [int(s) for s in input().split()]
	string = input()
	j = 0
	array = []
	for i in range(len(string)):
		if string[i] == '0':
			array.append(i)
	added = 0
	j = 0
	while j < len(array):
		if k > 0:
			diff = min(k, array[j] - added)
			if k < array[j] - added:
				array[j] = added + (array[j] - added - k)
			else:
				array[j] = added
			k -= diff
			added += 1
			j += 1
		else:
			break
	ans = ['1'] * n
	for idx in array:
		ans[idx] = '0'
	print(''.join(ans))


import math
import sys
from collections import defaultdict, Counter, deque, OrderedDict
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]
from itertools import accumulate, groupby
for _ in range(int(input())):
	(n, k) = ilele()
	s = input()
	l = []
	for i in range(n):
		if s[i] == '0':
			l.append(i)
	for i in range(len(l)):
		if l[i] - i <= k:
			k -= l[i] - i
			l[i] = i
		else:
			l[i] -= k
			k = 0
	li = ['1'] * n
	for i in l:
		li[i] = '0'
	print(''.join(li))


q = int(input().strip())
for _ in range(q):
	(n, k) = map(int, input().strip().split())
	a = input().strip()
	r = ''
	c = 0
	for i in range(n):
		if a[i] == '1':
			c += 1
		elif k >= c:
			r += '0'
			k -= c
		else:
			x = c - k
			r += '1' * x + '0' + '1' * k
			r += a[i + 1:]
			break
		if i == n - 1 and c:
			r += '1' * c
	print(r)


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = list(input())
	length = len(s)
	i = 0
	l = list([])
	for x in range(length):
		if s[x] == '0':
			l.append(x)
	cnt = len(l)
	while i < cnt and k > 0:
		ind = l[i]
		if ind == -1:
			break
		if k >= ind - i:
			k -= ind - i
			(s[i], s[ind]) = (s[ind], s[i])
		else:
			(s[ind - k], s[ind]) = (s[ind], s[ind - k])
			k = 0
		i += 1
	print(''.join(s))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	(n, k) = map(int, input().split())
	vals = [int(b) for b in input()]
	moves = k
	zeros = []
	for s in range(n):
		if vals[s] == 0:
			zeros.append(s)
	zeros.reverse()
	cv = 0
	while moves > 0 and len(zeros) > 0:
		v1 = zeros.pop()
		if v1 != cv:
			(vals[v1], vals[max(cv, v1 - moves)]) = (vals[max(cv, v1 - moves)], vals[v1])
			moves -= v1 - max(cv, v1 - moves)
		cv += 1
	vals = [str(b) for b in vals]
	print(''.join(vals))


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	s = list(str(input()))
	cnt = 0
	ans = []
	for i in range(n):
		if k > 0:
			if s[i] == '1':
				cnt += 1
			elif cnt < k:
				ans.append('0')
				k -= cnt
			else:
				ans += ['1'] * (cnt - k)
				ans.append('0')
				ans += ['1'] * k
				k = 0
		else:
			ans.append(s[i])
	if k:
		ans += ['1'] * cnt
	print(''.join(ans))


def main():
	q = int(input())
	while q > 0:
		(n, k) = map(int, input().split())
		arr = list(input())
		res = []
		a = 0
		b = 0
		for i in range(n):
			if k == 0:
				if b > 0:
					res.append('1' * b)
					b = 0
					res.extend(arr[i:])
				else:
					res.extend(arr[i:])
				break
			if arr[i] == '0':
				a += 1
				if a > 0 and b == 0:
					a -= 1
					res.append('0')
				elif a > 0 and b > 0:
					if k >= b:
						k -= b
					else:
						res.append('1' * (b - k))
						b = k
						k = 0
					a -= 1
					res.append('0')
			else:
				b += 1
		res.append('1' * b)
		print(*res, sep='')
		q -= 1
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	ans = ['1'] * n
	j = 0
	for i in range(n):
		if s[i] == '0':
			p = min(k, i - j)
			k -= p
			ans[i - p] = '0'
			j += 1
	print(''.join(ans))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	res = ''
	pri = False
	cnt = 0
	for i in range(n):
		if s[i] == '0':
			if cnt <= k:
				res += '0'
				k -= cnt
			else:
				a = cnt - k
				res += ('1' + '') * a
				res += '0'
				res += ('1' + '') * k
				res += s[i + 1:]
				print(res)
				pri = True
				break
		else:
			cnt += 1
	if not pri:
		res += ('1' + '') * cnt
		print(res)


q = int(input())
for t in range(q):
	(n, k) = [int(i) for i in input().split(' ')]
	s = list(input())
	zero = []
	for i in range(len(s)):
		if s[i] == '0':
			zero.append(i)
	var = 0
	index = 0
	while k > 0 and var < len(zero) and (index < len(s)):
		temp = zero[var]
		if k < zero[var] - index:
			(s[zero[var] - k], s[zero[var]]) = (s[zero[var]], s[zero[var] - k])
			k = 0
		else:
			(s[index], s[zero[var]]) = (s[zero[var]], s[index])
			k -= zero[var] - index
		var += 1
		index += 1
	print(''.join(s))


import math

def main():
	tests_count = int(input())
	for _ in range(0, tests_count):
		info = list(map(int, input().split()))
		len_total = info[0]
		moves_allowed = info[1]
		numbers_given = list(input())
		result = ['1'] * len_total
		best_place = 0
		for digit_position in range(len_total):
			if numbers_given[digit_position] == '0':
				moves_to_go = min(moves_allowed, digit_position - best_place)
				moves_allowed -= moves_to_go
				result[digit_position - moves_to_go] = '0'
				best_place += 1
		print(''.join(result))
main()


for iter in range(int(input())):
	numbers = list(map(int, input().split()))
	(a, b) = (numbers[0], numbers[1])
	string = input()
	counter = 0
	ans = ''
	flag = 0
	for i in range(a):
		if string[i] == '0':
			counter += 1
			ans = ans + '0'
			b += counter - i - 1
		if b <= 0:
			flag = 1
			if b != 0:
				lenght = len(ans) - 1
				ans = '0' * lenght
				ans += '1' * -b
				ans += '0'
			counter1 = 0
			anses = ''
			for iterator in range(a):
				if string[iterator] == '0' and counter > counter1:
					anses += '1'
					counter1 += 1
				else:
					anses += string[iterator]
			ans += anses[len(ans):]
			break
	if flag:
		print(ans)
	else:
		print(ans + '1' * (a - len(ans)))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input().strip())
	ze = 0
	on = -1
	for j in range(n):
		if on == -1 and s[j] == '1':
			on = j
		if s[j] == '0' and on != -1:
			if j - on <= k:
				k -= j - on
				(s[j], s[on]) = (s[on], s[j])
			else:
				(s[j], s[j - k]) = (s[j - k], s[j])
				k = 0
			on += 1
		if k == 0:
			break
	print(''.join(s))


q = int(input())
for i in range(q):
	(n, k) = [int(x) for x in input().split(' ')]
	s = input()
	res = ''
	count = 0
	for i in range(n):
		if s[i] == '0':
			if count <= k:
				res += '0'
				k -= count
			else:
				res += '1' * (count - k) + '0' + '1' * k + s[i + 1:]
				break
		else:
			count += 1
	res += '1' * max(n - len(res), 0)
	print(res)


def solve():
	(n, k) = map(int, input().split())
	s = input()
	zeros = []
	ans = ['1'] * n
	for i in range(n):
		if s[i] == '0':
			zeros.append(i)
	ptr = 0
	sz = len(zeros)
	for i in range(n):
		if ptr < sz and zeros[ptr] - i <= k:
			k -= zeros[ptr] - i
			ptr += 1
			ans[i] = '0'
	print(''.join(ans))
tt = int(input())
while tt > 0:
	solve()
	tt -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	i = 0
	l = n
	if a.count('1') > 0:
		l = a.index('1')
		i = l
	while i < n and k > 0 and (l < n):
		if a[i] == '0':
			if i - l <= k:
				k -= i - l
				(a[i], a[l]) = ('1', '0')
				for j in range(l, n):
					if a[j] == '1':
						l = j
						break
				else:
					break
			elif k > 0:
				(a[i], a[i - k]) = ('1', '0')
				k = 0
		i += 1
	print(''.join(map(str, a)))


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from collections import *
for _ in range(int(read())):
	(n, k) = readi()
	num = list(read())
	index = 0
	marks = list()
	swaps = list()
	for (i, bit) in enumerate(num):
		if bit == '0':
			swaps.append(i - index)
			index += 1
			marks.append(i)
	index = 0
	for (i, val) in enumerate(swaps):
		if k > val:
			k -= val
			num[marks[i]] = '1'
			num[index] = '0'
			index += 1
		else:
			k = val - k
			num[marks[i]] = '1'
			num[index + k] = '0'
			break
	print(''.join(num))


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	s = input()
	mas = []
	for i in range(n):
		if s[i] == '0':
			mas.append(i)
	for i in range(len(mas)):
		if mas[i] - i <= k:
			k -= mas[i] - i
			mas[i] = i
		else:
			mas[i] -= k
			break
	num = 0
	for i in range(n):
		if num < len(mas) and mas[num] == i:
			print(0, end='')
			num += 1
		else:
			print(1, end='')
	print()


class Case:

	def __init__(self, size, moves, string):
		self.size = size
		self.moves = moves
		self.string = string
SPACE = ' '
ZERO = '0'
ONE = '1'

def get_case():
	line_elements = input().split(SPACE)
	size = int(line_elements[0])
	moves = int(line_elements[1])
	string = list(input())
	return Case(size, moves, string)

def get_zero_indices(string):
	zero_indices = []
	for (index, char) in enumerate(string):
		if char == ZERO:
			zero_indices.append(index)
	return zero_indices

def get_zero_indices_after_moves(initial_zero_indices, ideal_indices, moves):
	final_zero_indices = []
	if len(initial_zero_indices) != len(ideal_indices):
		raise ValueError('initial_zero_indices and ideal_indices should be of the same length')
	for (i, zero_index) in enumerate(initial_zero_indices):
		if moves < 0:
			raise ValueError('moves should be >= 0')
		if moves == 0:
			final_zero_indices.extend(initial_zero_indices[i:])
			return final_zero_indices
		desired_moves = zero_index - ideal_indices[i]
		allowed_moves = min(moves, desired_moves)
		new_zero_index = zero_index - allowed_moves
		final_zero_indices.append(new_zero_index)
		moves = moves - allowed_moves
	return final_zero_indices

def add_zeros(ones, zero_indices):
	for index in zero_indices:
		ones[index] = ZERO
	return ones

def solve(case):
	initial_zero_indices = get_zero_indices(case.string)
	ideal_zero_indices = list(range(len(initial_zero_indices)))
	final_zero_indices = get_zero_indices_after_moves(initial_zero_indices, ideal_zero_indices, case.moves)
	ones = [ONE] * case.size
	response = add_zeros(ones, final_zero_indices)
	return response
number_of_cases = int(input())
for i in range(number_of_cases):
	case = get_case()
	solvedList = solve(case)
	solution = ''.join(solvedList)
	print(solution)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	s = sys.stdin.readline()[:-1]
	ans = [0 for _ in range(n)]
	count = 0
	last = 0
	count0 = 0
	z = True
	for i in range(n):
		if s[i] == '1':
			count += 1
		elif k >= count:
			count0 += 1
			k -= count
		else:
			z = False
			break
	if z:
		k = 0
	for i in range(count0):
		ans[i] = '0'
	for i in range(count0, count0 + (count - k)):
		ans[i] = '1'
	if i + 1 < n:
		ans[i + 1] = '0'
	rem = i + 1
	for j in range(k):
		if rem + 1 + j >= n:
			break
		ans[rem + 1 + j] = '1'
	last = rem + 1 + k
	for j in range(last, n):
		ans[j] = s[j]
	print(''.join((x for x in ans)))


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = input()
	zeros = [i for i in range(n) if s[i] == '0']
	(i, buffer) = (0, 0)
	for i in range(len(zeros)):
		if k == 0:
			break
		(zeros[i], k) = (max(buffer, zeros[i] - k), max(k - (zeros[i] - buffer), 0))
		buffer += 1
	zeros.append(n)
	res = ['1' for i in range(zeros[0])]
	for i in range(len(zeros) - 1):
		res.append('0')
		res.extend(['1' for i in range(zeros[i + 1] - zeros[i] - 1)])
	print(''.join(res))


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	s = [i for i in input()]
	count = 0
	start = 0
	pos = [i for i in range(n)]
	for i in range(n):
		if s[i] == '0':
			dist = max(start, i - k)
			if k >= i - dist:
				pos[i] = dist
				if dist == start:
					start += 1
				k -= i - dist
			else:
				break
	ans = ['1'] * n
	for i in range(n):
		if s[i] == '0':
			ans[pos[i]] = '0'
	print(''.join(ans))


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	l = list(input())
	a = []
	ones = 0
	lit = []
	for i in range(n):
		if l[i] == '1':
			lit.append(i)
			ones = i
			break
	z = 0
	for i in range(ones):
		if l[i] == '0':
			z += 1
	for i in range(ones, n, 1):
		if l[i] == '0':
			a.append(i)
	if len(a) != 0 and len(lit) != 0:
		for i in range(len(a)):
			if k > 0:
				x = min(k, a[i] - z)
				l[a[i] - x] = '0'
				l[a[i]] = '1'
				k -= x
			z += 1
	for i in range(n):
		print(l[i], end='')
	print()


N = int(input())
while N > 0:
	N = N - 1
	(length, n) = map(int, input().strip().split())
	s = input()
	cnt_1 = 0
	cnt_0 = 0
	ans = ''
	for (k, v) in enumerate(s):
		if v == '0':
			if n >= cnt_1:
				n -= cnt_1
			else:
				ans = '0' * cnt_0
				ans += '1' * (k - cnt_0)
				ans += s[k:]
				ans = list(ans)
				(ans[k], ans[cnt_0 + cnt_1 - n]) = (ans[cnt_0 + cnt_1 - n], ans[k])
				ans = ''.join(ans)
				break
			cnt_0 += 1
		else:
			cnt_1 += 1
	if not ans:
		ans = '0' * cnt_0 + '1' * cnt_1
	print(ans)


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def gcd(a, b):
	while b:
		a = a % b
		(b, a) = (a, b)
	return a

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	(n, k) = mp()
	s = input()
	if '1' in s:
		a = s.index('1')
		if a == n - 1:
			print(s)
			return
	else:
		print(s)
		return
	l = ['0'] * a + ['1'] * (n - a)
	x = [i for i in range(a + 1, n) if s[i] == '0']
	p = a
	for i in range(len(x)):
		if k == 0:
			break
		if x[i] <= k + p:
			k = k - x[i] + p
			l[p] = '0'
			x[i] = 0
			p += 1
		else:
			l[x[i] - k] = '0'
			x[i] = 0
			k = 0
	for i in x:
		if i != 0:
			l[i] = '0'
	print(''.join(l))
for _ in range(inp()):
	solve()


import heapq
from sys import stdin, stdout
from collections import defaultdict

def main():
	for _ in range(int(input())):
		(n, k) = map(int, stdin.readline().split())
		st = stdin.readline().strip()
		lis = []
		for i in range(n):
			if st[i] == '0':
				lis.append(i)
		arr = list(st)
		value = 0
		for i in range(len(lis)):
			if lis[i] - value == 0:
				value += 1
				continue
			else:
				slide = lis[i] - 1 - value + 1
				if slide < k:
					temp = arr[value]
					arr[value] = arr[lis[i]]
					arr[lis[i]] = temp
					value += 1
					k -= slide
				else:
					rem = lis[i] - k
					temp = arr[rem]
					arr[rem] = arr[lis[i]]
					arr[lis[i]] = temp
					break
		print(''.join(arr))
main()


import io, sys, atexit, os
import math as ma
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

def li():
	return list(map(int, sys.stdin.readline().split()))

def num():
	return map(int, sys.stdin.readline().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007

def solve():
	t = nu()
	for tt in range(t):
		(n, k) = num()
		s = list(input())
		ol = [0] * (n + 1)
		move = 0
		last = 0
		ind = -1
		for i in range(n):
			if s[i] == '0':
				ox = i - last
				if k - ox >= 0:
					k -= ox
				else:
					ind = i
					break
				last += 1
		if ind == -1:
			s.sort()
			print(*s, sep='')
		else:
			op = s[0:ind]
			oz = s[ind:]
			op.sort()
			op += oz
			while k > 0:
				(op[ind - 1], op[ind]) = (op[ind], op[ind - 1])
				ind -= 1
				k -= 1
			print(*op, sep='')

def __starting_point():
	solve()
__starting_point()


def solve_dd(st, k):
	arr = list(map(int, st))
	positions = [i for i in range(len(arr)) if not arr[i]]
	left = 0
	i = 0
	while True:
		if i >= len(positions) or k <= positions[i] - left:
			break
		k -= positions[i] - left
		positions[i] = left
		left += 1
		i += 1
	if i < len(positions):
		positions[i] = positions[i] - k
	ans = [1] * len(st)
	for item in positions:
		ans[item] = 0
	return ans
q = int(input())
for i in range(q):
	(_, k) = list(map(int, input().split()))
	st = input()
	res = solve_dd(st, k)
	print(''.join(map(str, res)))


from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
mod = 10 ** 9 + 7
q = int(input())
for _ in range(q):
	(n, k) = list(map(int, input().split()))
	s = list(input())
	cnt = 0
	flag = 0
	yo = 0
	ha = 0
	for i in range(n):
		if s[i] == '0':
			if cnt <= k:
				k -= cnt
				yo += 1
			else:
				flag = 1
				ha = k
				break
		else:
			cnt += 1
	if flag == 0:
		z = list(map(int, s))
		z.sort()
		z = list(map(str, z))
		print(''.join(z))
	else:
		ans = []
		for i in range(yo):
			ans.append('0')
		cnt = 0
		ma = 0
		for (j, i) in enumerate(s):
			if i == '1':
				ma += 1
			if i == '0':
				cnt += 1
			if cnt > yo:
				posn = j
				break
		z = ['1' * (ma - ha) + '0'] + ['1' * ha]
		z1 = s[posn + 1:]
		ans += z + z1
		print(''.join(ans))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	zero = 0
	val = a.count('0')
	rem = n - val
	if k >= rem * val:
		a.sort()
		print(''.join((str(i) for i in a)))
	else:
		for i in range(n):
			if a[i] == '0':
				zero += 1
			else:
				break
		for i in range(zero, n):
			if a[i] == '0':
				if k >= i - zero:
					(a[i], a[zero]) = (a[zero], a[i])
					k -= i - zero
					zero += 1
				else:
					(a[i], a[i - k]) = (a[i - k], a[i])
					break
		print(''.join((str(i) for i in a)))


cases = int(input())
for _ in range(cases):
	[n, k] = list(map(int, input().split()))
	moves = 0
	string = list(input())
	last_zero_idx = -1
	for i in range(n):
		if string[i] == '0':
			if moves == 0:
				_i = i
				while _i > 0 and moves < k and (string[_i - 1] != '0'):
					temp = string[_i]
					string[_i] = string[_i - 1]
					string[_i - 1] = temp
					_i -= 1
					moves += 1
				last_zero_idx = _i
			else:
				backwards_jump = min(i - last_zero_idx - 1, k - moves)
				_j = i - backwards_jump
				temp = string[i]
				string[i] = string[_j]
				string[_j] = temp
				moves += backwards_jump
				last_zero_idx = _j
		if moves >= k:
			break
	string = ''.join(string)
	print(string)


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = list(input())
	c = k
	try:
		pzero = s.index('1')
	except ValueError:
		print(''.join(s))
		continue
	pone = 0
	while c > 0:
		try:
			pzero = s.index('0', pzero)
			pone = s.index('1', max(pone, pzero - c))
		except ValueError:
			break
		s[pzero] = '1'
		s[pone] = '0'
		c -= pzero - pone
	print(''.join(s))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, list(input())))
	i = 0
	temp = 0
	prev = 0
	while i < n and k > 0:
		if a[i] == 1:
			i += 1
		else:
			sw = min(k, i - prev)
			k -= sw
			(a[i - sw], a[i]) = (a[i], a[i - sw])
			prev = i - sw + 1
			i += 1
	for i in a:
		print(i, end='')
	print('')


import sys
q = int(input())
for qi in range(q):
	(n, k) = list(map(int, input().split()))
	s = list(input())
	s = [0 if x == '0' else 1 for x in s]
	zc = oc = 0
	found = False
	for i in range(len(s)):
		if s[i] == 1:
			oc += 1
		elif oc <= k:
			k -= oc
			zc += 1
		else:
			res = [0] * zc
			res += [1] * (oc - k)
			res += [0]
			res += [1] * k
			res += s[i + 1:]
			print(''.join((str(x) for x in res)))
			found = True
			break
	if not found:
		res = [0] * zc
		res += [1] * oc
		print(''.join((str(x) for x in res)))


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	cnt = 0
	ans = list()
	flag = 0
	for i in range(n):
		if s[i] == '1':
			cnt += 1
		elif cnt <= k:
			ans.append('0')
			k -= cnt
		else:
			for j in range(cnt - k):
				ans.append('1')
			ans.append(0)
			for j in range(k):
				ans.append('1')
			for j in range(i + 1, n):
				ans.append(s[j])
			flag = 1
			break
	if not flag:
		for j in range(cnt):
			ans.append('1')
	for j in range(len(ans)):
		print(ans[j], end='')
	print()


n = int(input())
for i in range(n):
	(n, k) = map(int, input().split(' '))
	stri = input()
	result = ['1'] * n
	t = 0
	for j in range(n):
		if stri[j] == '0':
			s = min(k, j - t)
			k -= s
			result[j - s] = '0'
			t += 1
	print(''.join(result))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = input()
	ans = ''
	ones = 0
	zeros = 0
	flag = 0
	for i in range(n):
		if s[i] == '1':
			ones = ones + 1
		elif k >= ones:
			k = k - ones
			zeros = zeros + 1
		else:
			ans = '0' * zeros + '1' * (ones - k) + '0' + '1' * k + s[i + 1:]
			flag = 1
			break
	if flag == 0:
		ans = '0' * zeros + '1' * ones
	print(ans)


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	line = list(input())
	zero = 0
	non_zero = 0
	while zero < n:
		if line[zero] != '0':
			zero += 1
			continue
		pos = zero
		if zero - non_zero < k:
			k -= zero - non_zero
			line[zero] = '1'
			line[non_zero] = '0'
			non_zero += 1
		else:
			line[zero - k] = '0'
			line[zero] = '1'
			break
		if k == 0:
			break
		zero += 1
	print(*line, sep='')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	lis = list(input().strip())
	j = 0
	for i in range(n):
		if lis[i] == '0':
			need = i - j
			if k - need < 0:
				need = k
				k = 0
			else:
				k -= need
			j = i - need
			(lis[j], lis[i]) = (lis[i], lis[j])
			j += 1
		if k == 0:
			break
	print(*lis, sep='')


def solve(n, k, s):
	ind = []
	flag = 0
	for q in range(n):
		if s[q] == '0' and flag == 0:
			continue
		if s[q] == '1':
			flag = 1
		if s[q] == '0' and flag == 1:
			ind.append(q + 1)
	if len(ind) == 0 or len(ind) == n:
		print(''.join(map(str, s)))
		return
	s = list(map(int, s))
	s.insert(0, -1)
	j = 0
	for i in range(1, n + 1):
		if k == 0 or j == len(ind):
			break
		if s[i] == 0:
			continue
		if ind[j] - i <= k:
			(s[i], s[ind[j]]) = (s[ind[j]], s[i])
			k -= ind[j] - i
			j += 1
		else:
			(s[ind[j] - k], s[ind[j]]) = (s[ind[j]], s[ind[j] - k])
			j += 1
			break
	s.remove(-1)
	print(''.join(map(str, s)))
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	solve(n, k, s)


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	A = input()
	g = 0
	j = 0
	s = 0
	while j < n and k > 0:
		if A[j] == '0':
			if j - g <= k:
				s = g
				k -= j - g
			else:
				s = j - k
				k = 0
			g += 1
		j += 1
	if g > 0:
		A = '0' * (g - 1) + (s - g + 1) * '1' + '0' + '1' * (j - s - 1) + A[j:]
	else:
		A = '0' * (g - 1) + (s - g + 1) * '1' + '1' * (j - s - 1) + A[j:]
	print(A)


import sys, math, queue, collections
MOD = 10 ** 9 + 7
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	(p, z) = (0, 0)
	done = False
	for i in range(n):
		if a[i] == '1':
			continue
		if k < i - p:
			a = ['0'] * z + ['1'] * (i - z) + a[i:]
			done = True
			break
		else:
			k -= i - p
			z += 1
			p += 1
	if not done:
		a = ['0'] * z + ['1'] * (n - z) + a[n:]
	for i in range(1, n):
		if a[i - 1] == '1' and a[i] == '0':
			j = i
			while k > 0:
				a[j - 1] = '0'
				a[j] = '1'
				k -= 1
				j -= 1
			break
	print(''.join(a))


t = int(input())
while t > 0:
	t -= 1
	a = list(map(int, input().split()))
	s = input()
	ans = ''
	tmp = 0
	n = a[0]
	k = a[1]
	for i in range(n):
		if k >= 0:
			if s[i] == '1':
				tmp += 1
				if i == n - 1:
					for x in range(tmp):
						ans += '1'
			else:
				if k >= tmp:
					ans += '0'
					if i == n - 1:
						for x in range(tmp):
							ans += '1'
				else:
					for x in range(tmp - k):
						ans += '1'
					ans += '0'
					for x in range(k):
						ans += '1'
				k -= tmp
		else:
			ans += s[i]
	print(ans)


for _ in range(int(input())):
	(n, K) = map(int, input().split())
	ind = []
	s = input()
	for i in range(n):
		if s[i] == '0':
			ind.append(i)
	cnt = K
	for i in range(len(ind)):
		if cnt < ind[i] - i:
			ind[i] -= cnt
			cnt = 0
		else:
			cnt -= ind[i] - i
			ind[i] = i
	ans = ['@' for i in range(n)]
	for i in ind:
		ans[i] = '0'
	for i in range(n):
		if ans[i] == '@':
			ans[i] = '1'
	print(''.join((str(x) for x in ans)))


from collections import defaultdict

def inp1():
	return map(int, input().split())

def inp():
	return list(inp1())

def num():
	return int(input())
for _ in range(num()):
	(n, k) = inp1()
	s = list(input())
	i = 0
	mark = None
	while k > 0 and i < n:
		if s[i] == '1':
			if mark == None:
				mark = i
		elif mark != None:
			if i - mark <= k:
				(s[i], s[mark]) = (s[mark], s[i])
				k -= i - mark
				mark += 1
			else:
				(s[i], s[i - k]) = (s[i - k], s[i])
				break
		i += 1
	print(''.join(s))


q = int(input())
import sys
input = sys.stdin.readline
for i in range(q):
	(n, k) = map(int, input().split())
	s = sys.stdin.readline().rstrip()
	z = [-1]
	for j in range(n):
		if s[j] == '0':
			z.append(j)
	for j in range(1, len(z)):
		if k >= z[j] - z[j - 1] - 1:
			k -= z[j] - z[j - 1] - 1
			z[j] = z[j - 1] + 1
		elif k > 0:
			z[j] -= k
			k = 0
			break
		else:
			break
	if k > 0:
		print('0' * (len(z) - 1) + '1' * (n - len(z) + 1))
		continue
	ans = ['1'] * n
	for j in range(1, len(z)):
		ans[z[j]] = '0'
	r = ''
	for j in range(n):
		if j < n - 1:
			print(ans[j], end='')
		else:
			print(ans[j])


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	z = []
	a = list(input())
	for i in range(n):
		if a[i] == '0':
			z.append(i)
	y = 0
	for i in range(len(z)):
		if k - (z[i] - y) > 0:
			k -= z[i] - y
			z[i] = y
			y += 1
		else:
			z[i] -= k
			break
	v = [0 for i in range(n)]
	for i in range(len(z)):
		a[z[i]] = '0'
		v[z[i]] = 1
	for i in range(n):
		if v[i] == 0:
			a[i] = '1'
	print(''.join(a))


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	zeroes = [i for (i, x) in enumerate(s) if x == '0']
	out = ''
	for (i, zero) in enumerate(zeroes):
		ones = zero - i
		if k - ones > 0:
			k -= ones
			out += '0'
		else:
			out += '1' * (ones - k) + '0' + '1' * k + s[zero + 1:]
			k = 0
			break
	if k:
		if not zeroes:
			out = s
		else:
			out += '1' * (len(s) - len(out))
	print(out)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
mod = 998244353
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	(n, k) = inp()
	s = list(ips())
	if len(set(s)) == 1:
		ans = ''.join(s)
		out(ans)
	else:
		i = 0
		ch = deque()
		pt = 0
		i = 0
		mark = [False] * n
		ans = []
		for i in range(n):
			if s[i] == '0':
				ans.append('0')
			else:
				pos = i
				break
		for i in range(pos, n):
			if s[i] == '0':
				ch.append(i)
		ct = pos
		while len(ch) != 0:
			ele = ch.popleft()
			diff = ele - ct
			if k >= diff:
				k -= diff
				mark[ele] = True
				ans.append('0')
				ct += 1
			else:
				break
		for i in range(pos, n):
			if mark[i]:
				pass
			else:
				ans.append(s[i])
		check = 0
		for i in range(n):
			if ans[i] == '0':
				check += 1
			else:
				pos = i
				break
		if check == ans.count('0'):
			pass
		else:
			zero = None
			for i in range(pos, n):
				if ans[i] == '0':
					zero = i
					break
			for i in range(zero, pos, -1):
				if k == 0:
					break
				else:
					(ans[i], ans[i - 1]) = (ans[i - 1], ans[i])
					k -= 1
		ans = ''.join(ans)
		out(ans)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	binary_string = list(input())
	ans = ['1'] * n
	last_zero = 0
	for i in range(0, len(binary_string)):
		if binary_string[i] == '0':
			swaps = min(k, i - last_zero)
			k -= swaps
			ans[i - swaps] = '0'
			last_zero += 1
	print(''.join(ans))


class Case:

	def __init__(self, size, moves, string):
		self.size = size
		self.moves = moves
		self.string = string
SPACE = ' '
ZERO = '0'
ONE = '1'

def get_case():
	line_elements = input().split(SPACE)
	size = int(line_elements[0])
	moves = int(line_elements[1])
	string = list(input())
	return Case(size, moves, string)

def swap(index, next_zero_index, string):
	(string[index], string[next_zero_index]) = (string[next_zero_index], string[index])
	return string

def zeros(string):
	zero_indices = []
	for (index, char) in enumerate(string):
		if char == ZERO:
			zero_indices.append(index)
	return zero_indices

def final_zeros(zi, ideal, moves):
	final_zero_indices = []
	if len(zi) != len(ideal):
		raise ValueError('zi and ideal should be of the same length')
	for (i, zi_value) in enumerate(zi):
		if moves < 0:
			raise ValueError('moves should be >= 0')
		if moves == 0:
			final_zero_indices.extend(zi[i:])
			return final_zero_indices
		desired_moves = zi_value - ideal[i]
		allowed_moves = min(moves, desired_moves)
		moves = moves - allowed_moves
		final_zero_indices.append(zi_value - allowed_moves)
	return final_zero_indices

def fill(zero_indices, size):
	ones = [ONE] * size
	for index in zero_indices:
		ones[index] = ZERO
	return ones

def solve(case):
	zi = zeros(case.string)
	ideal = list(range(len(zi)))
	fi = final_zeros(zi, ideal, case.moves)
	response = fill(fi, case.size)
	return response
number_of_cases = int(input())
for i in range(number_of_cases):
	case = get_case()
	solvedList = solve(case)
	solution = ''.join(solvedList)
	print(solution)


import sys
input = sys.stdin.readline
q = int(input())
for testcases in range(q):
	(n, k) = map(int, input().split())
	S = input().strip()
	count = 0
	LIST = [0]
	for s in S:
		if s == '1':
			count += 1
		else:
			LIST.append(count)
	ind = 1
	while ind < len(LIST) and k > 0:
		if LIST[ind] <= k:
			k -= LIST[ind]
			LIST[ind] = 0
		else:
			LIST[ind] -= k
			k = 0
		ind += 1
	ones = 0
	ANS = []
	for i in range(1, len(LIST)):
		ANS += [1] * (LIST[i] - LIST[i - 1])
		ANS.append(0)
	ANS += [1] * (count - LIST[-1])
	print(''.join(map(str, ANS)))


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	[n, k] = list(map(lambda x: int(x), input().rstrip().split()))
	givenStr = input().rstrip()
	count0 = 0
	for index in range(0, len(givenStr)):
		if givenStr[index] == '0':
			expectedIndex = count0
			movesReq = index - expectedIndex
			if movesReq <= k:
				k -= movesReq
				count0 += 1
			else:
				ans = '0' * count0
				count1 = index - count0
				ans += '1' * count1
				if k > 0:
					ans = list(ans)
					ans[-1 * k] = '0'
					ans.append('1')
					ans += givenStr[index + 1:]
					print(''.join(ans))
				else:
					ans += givenStr[index:]
					print(ans)
				break
	else:
		ans = '0' * count0 + '1' * (n - count0)
		print(ans)


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = list(input())
	l = 0
	for i in range(n):
		if k <= 0:
			break
		if s[i] == '0':
			if k >= i - l:
				s[i] = s[l]
				s[l] = '0'
				k -= i - l
				l += 1
			else:
				s[i] = s[i - k]
				s[i - k] = '0'
				break
	print(''.join(s))


q = int(input())
for _ in range(q):
	(n, k) = list(map(int, input().split()))
	s = list(input())
	count = 0
	for j in s:
		if j == '1':
			break
		count += 1
	for i in range(count, n):
		if k == 0:
			break
		if s[i] == '1':
			continue
		if k >= i - count:
			k -= i - count
			s[count] = '0'
			s[i] = '1'
			count += 1
		else:
			s[i - k] = '0'
			s[i] = '1'
			break
	print(''.join(s))


for i in range(int(input())):
	(n, k) = map(int, input().split(' '))
	a = list(input())
	cnt = 0
	for i in range(len(a)):
		if a[i] == '0' and k > 0:
			mn = min(k, cnt)
			k -= mn
			(a[i], a[i - mn]) = (a[i - mn], a[i])
		else:
			cnt += 1
	print(''.join(a))


for _ in range(int(input())):
	(am, k) = list(map(int, input().split()))
	arr = list(map(int, list(input())))
	iBest = -1
	for i in range(am):
		if arr[i] == 0:
			maxPlace = max(iBest + 1, i - k)
			iBest = maxPlace
			k -= i - maxPlace
			(arr[i], arr[maxPlace]) = (arr[maxPlace], arr[i])
	print(*arr, sep='')


import io, os
input = io.StringIO(os.read(0, os.fstat(0).st_size).decode()).readline
ii = lambda : int(input())
kk = lambda : map(int, input().split())
ll = lambda : list(kk())
for _ in range(ii()):
	(n, k) = kk()
	s = list(input()[:-1])
	lind = 0
	for i in range(n):
		if s[i] == '0':
			if k >= i - lind:
				(s[lind], s[i]) = (s[i], s[lind])
				k -= i - lind
				lind += 1
			else:
				v = i - k
				(s[v], s[i]) = (s[i], s[v])
				break
	print(''.join(s))


q = int(input())
for fwee in range(q):
	(n, k) = map(int, input().split())
	s = input()
	zera = []
	for i in range(n):
		if s[i] == '0':
			zera.append(i)
	pos = 0
	while k > 0 and pos < len(zera):
		co = min(k, zera[pos] - pos)
		zera[pos] -= co
		pos += 1
		k -= co
	odp = [1] * n
	for i in zera:
		odp[i] = 0
	for i in range(n):
		if i < n - 1:
			print(odp[i], end='')
		else:
			print(odp[i])


t = int(input())
final = []
for i in range(t):
	(n, k) = map(int, input().split())
	s = input()
	s = list(s)
	zero = []
	for i in range(n):
		if s[i] == '0':
			zero += [i]
	ind = 0
	lol = 0
	for x in zero:
		if x - lol > k:
			break
		temp = s[x]
		s[x] = s[lol]
		s[lol] = temp
		k -= x - lol
		ind += 1
		lol += 1
	if ind == len(zero):
		for x in s:
			print(x, end='')
		print('')
		continue
	ind = zero[ind]
	temp = s[ind]
	s[ind] = s[ind - k]
	s[ind - k] = temp
	for x in s:
		print(x, end='')
	print('')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = list(input())
	(ln, i, firstind, aage) = (len(l), 0, -1, 0)
	while i < ln and k:
		if l[i] == '1':
			if firstind == -1:
				firstind = i
			aage += 1
		elif l[i] == '0' and firstind != -1:
			if k >= aage:
				l[firstind] = '0'
				firstind += 1
				l[i] = '1'
				k -= aage
			elif k < aage:
				l[i - k] = '0'
				l[i] = '1'
				k -= k
				break
		i += 1
	print('\n' + ''.join(l))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	ans = ['1'] * n
	t = 0
	for j in range(n):
		if a[j] == '0':
			s = min(k, j - t)
			k -= s
			ans[j - s] = '0'
			t += 1
	print(''.join(ans))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s = list(s)
	p = 0
	for i in range(n):
		if s[i] == '0':
			if k >= i - p:
				s[i] = '1'
				s[p] = '0'
				k -= i - p
				p += 1
			else:
				s[i - k] = '0'
				s[i] = '1'
				break
			if k == 0:
				break
	for i in s:
		print(i, end='')
	print()


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		(n, k) = ain()
		s = list(sin())
		co = 0
		for i in range(n):
			if s[i] == '1':
				co = min(k, co + 1)
			elif co != 0:
				s[i - co] = '0'
				s[i] = '1'
				k -= co
				co = min(co, k)
		print(''.join(s))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


q = int(input())
for t in range(q):
	(n, k) = map(int, input().split())
	a = input()
	ko = 0
	used = [0] * n
	ans = ''
	g = True
	for i in range(n):
		if a[i] == '1':
			ko += 1
		elif ko <= k:
			k -= ko
			ans = ans + '0'
		else:
			for j in range(ko - k):
				ans = ans + '1'
			ans = ans + '0'
			for j in range(k):
				ans = ans + '1'
			for j in range(i + 1, n):
				ans = ans + a[j]
			print(ans)
			g = False
			break
	if g == True:
		for j in range(ko):
			ans = ans + '1'
		print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input()))
	k = []
	i = 0
	for tpp in range(n):
		if l[tpp] == 0:
			k.append(tpp)
	for t in range(len(k)):
		if m > 0:
			if t == 0:
				if m - k[t] >= 0:
					m -= k[t]
					k[t] -= k[t]
				else:
					k[t] = k[t] - m
					m -= m
			elif m - (k[t] - k[t - 1] - 1) >= 0:
				m -= k[t] - k[t - 1] - 1
				k[t] -= k[t] - k[t - 1] - 1
			else:
				k[t] = k[t] - m
				m -= m
		else:
			break
	ans = [1] * n
	for j in k:
		ans[j] = 0
	print(*ans, sep='')


import sys
input = sys.stdin.readline

def main():
	q = int(input())
	for _ in range(q):
		(N, K) = [int(x) for x in input().split()]
		S = input().strip()
		ans = [0] * N
		count = 0
		is_end = False
		for (i, s) in enumerate(S):
			if is_end:
				ans[i] = int(s)
				continue
			if s == '0':
				if count > 0:
					if count <= K:
						K -= count
					else:
						for j in range(i - count, i + 1):
							if j == i - K:
								continue
							ans[j] = 1
						is_end = True
			elif s == '1':
				count += 1
		if not is_end:
			zeroc = S.count('0')
			for i in range(N):
				if i > zeroc - 1:
					print('1', end='')
				else:
					print('0', end='')
			print('')
		else:
			print(''.join(map(str, ans)))
main()


q = int(input())
while q != 0:
	(n, k) = map(int, input().split())
	s = list(input())
	count = 0
	for i in range(len(s)):
		if s[i] == '0':
			if i - count <= k:
				(s[count], s[i]) = (s[i], s[count])
				k -= i - count
				count += 1
			else:
				(s[i - k], s[i]) = (s[i], s[i - k])
				break
	for i in range(len(s)):
		print(s[i], end='')
	print()
	q -= 1


Q = int(input())
for _ in range(Q):
	(n, k) = map(int, input().split())
	A = input()
	zeroes = [i for i in range(n) if A[i] == '0']
	for (target, orig) in enumerate(zeroes):
		if k == 0:
			break
		moves = min(k, orig - target)
		k -= moves
		zeroes[target] = orig - moves
	res = ['1' for i in range(n)]
	for z in zeroes:
		res[z] = '0'
	res = ''.join(res)
	print(res)


import sys
res = []
for _ in range(int(input())):
	(n, k) = map(int, sys.stdin.readline().split())
	s = sys.stdin.readline().rstrip()
	one = 0
	zero = 0
	ans = ''
	for i in range(n):
		if s[i] == '1':
			one += 1
		elif one <= k:
			zero += 1
			k -= one
		else:
			ans = '0' * zero + '1' * (one - k) + '0' + '1' * k + s[i + 1:]
			break
	else:
		ans = '0' * zero + '1' * one
	res.append(ans)
print(*res, sep='\n')


def solve(k, bits):
	indices = []
	for (i, b) in enumerate(bits):
		if b == '0':
			indices.append(i)
	cur = k
	for i in range(len(indices)):
		index = indices[i]
		move = index - i
		if move > cur:
			indices[i] = index - cur
			break
		else:
			indices[i] = i
			cur -= move
	ans = ['1'] * len(bits)
	for index in indices:
		ans[index] = '0'
	return ''.join(ans)

def __starting_point():
	q = int(input())
	for _ in range(q):
		(n, k) = [int(r) for r in input().split(' ')]
		print(solve(k, input()))
__starting_point()


import sys
import itertools
import math
import collections
from collections import Counter

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
t = ii()
for _ in range(t):
	(n, k) = mi()
	s = input()
	state = []
	pos = 0
	for i in range(n):
		if s[i] == '0':
			if k != 0 and i - pos <= k:
				state.append(pos)
				k -= i - pos
				pos += 1
			elif k != 0:
				state.append(i - k)
				k = 0
			else:
				state.append(i)
	res = [1] * n
	for i in state:
		res[i] = 0
	prr(res, '')


for a0 in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(input())
	f = True
	j = 0
	while k > 0 and j < n and f:
		while j < n and a[j] != '1':
			j += 1
		i = j
		f = False
		while i < n and j < n:
			if a[j] == '1' and a[i] == '0' and (k >= i - j):
				a[j] = '0'
				a[i] = '1'
				k = k - (i - j)
				while j < n and a[j] != '1':
					j += 1
			elif a[i] == '0' and k < i - j:
				f = True
				j = j + (i - j - k)
			else:
				i += 1
	print(*a, sep='')


test = int(input())
for _ in range(test):
	(n, k) = [int(x) for x in input().split()]
	string = input()
	lst = []
	for i in range(n):
		lst.append(string[i])
	res = []
	count = 0
	flag = False
	for i in range(n):
		if lst[i] == '0':
			if count <= k:
				res.append('0')
				k -= count
			else:
				temp = ['1'] * (count - k)
				res.extend(temp)
				res.append('0')
				temp = ['1'] * k
				res.extend(temp)
				res.extend(lst[i + 1:])
				str1 = ''.join(res)
				print(str1)
				flag = True
				break
		else:
			count += 1
	if flag == False:
		temp = ['1'] * count
		res.extend(temp)
		str1 = ''.join(res)
		print(str1)


import math

def bsm(s, k):
	s = [int(i) for i in s]
	n = len(s)
	fo = None
	rm = k
	for i in range(n):
		if s[i] == 1:
			fo = i
			break
	if fo is None:
		s = [str(i) for i in s]
		return ''.join(s)
	for i in range(n):
		if s[i] == 0 and i >= fo:
			d = i - fo
			if d <= rm:
				t = s[fo]
				s[fo] = s[i]
				s[i] = t
				fo = fo + 1
				rm -= d
			else:
				t = s[i - rm]
				s[i - rm] = s[i]
				s[i] = t
				break
	s = [str(i) for i in s]
	return ''.join(s)
q = int(input())
for i in range(q):
	nk = input()
	nk = nk.split(' ')
	n = int(nk[0])
	k = int(nk[1])
	s = input()
	print(bsm(s, k))


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
from collections import deque, Counter, OrderedDict, defaultdict
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		(n, k) = mi()
		s = list(si())
		pos = -1
		for i in range(n):
			if s[i] == '1':
				pos = i
				break
		if pos == -1:
			print(''.join(s))
			continue
		l = []
		for i in range(n):
			if s[i] == '0' and i > pos:
				l.append(i)
		j = 0
		while k > 0:
			if j == len(l):
				break
			p = l[j]
			j += 1
			if p - pos <= k:
				(s[p], s[pos]) = (s[pos], s[p])
				k -= p - pos
			else:
				(s[p], s[p - k]) = (s[p - k], s[p])
				k = 0
			pos += 1
		print(''.join(s))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for counter in range(int(input())):
	(n, k) = (int(x) for x in input().split())
	s = list(input())
	zeros = 0
	ones = 0
	a = []
	for i in range(n):
		if s[i] == '0':
			zeros += 1
			a.append(i)
	p = 0
	for i in range(n):
		if zeros > 0:
			if a[i] - i <= k:
				k -= a[i] - i
				s[a[i]] = '1'
				s[p] = '0'
				p += 1
				zeros -= 1
			else:
				q = 0
				s[a[i]] = '1'
				s[a[i] - k] = '0'
				break
		else:
			break
	for x in s:
		if x != 'a':
			print(x, end='')
	print()


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	st = list(input())
	kn = 0
	for i in range(n):
		if st[i] == '0':
			if i - kn <= k:
				t = st[i]
				st[i] = st[kn]
				st[kn] = t
				k -= i - kn
				if k == 0:
					break
			else:
				t = st[i]
				st[i] = st[i - k]
				st[i - k] = t
				break
			kn += 1
	for i in range(n):
		print(st[i], end='')
	print()


t = int(input())
for ij in range(0, t):
	(n, k) = map(int, input().split())
	s = list(input())
	l = []
	for i in range(0, n):
		if s[i] == '0':
			l.append(i)
	for i in range(0, len(l)):
		if l[i] != i:
			if k > l[i] - i:
				s[i] = '0'
				s[l[i]] = '1'
				k -= l[i] - i
			else:
				s[l[i] - k] = '0'
				s[l[i]] = '1'
				break
	for i in s:
		print(i, end='')
	print()


number_cases = int(input())
respostas = []
for i in range(number_cases):
	lista = []
	(n, k) = (int(i) for i in input().split())
	name_1 = input()
	m = 0
	tamanho_nome = len(name_1)
	for j in name_1:
		lista.append(j)
	for i in range(tamanho_nome):
		if name_1[i] == '0':
			if i - m <= k:
				lista[i] = '1'
				lista[m] = '0'
				k -= i - m
				m += 1
				if k == 0:
					break
			else:
				lista[i] = '1'
				lista[i - k] = '0'
				break
	respostas.append(''.join(lista))
for d in respostas:
	print(d)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(input().rstrip())
	l = 0
	for i in range(n):
		if a[i] == '0':
			k -= i - l
			if k >= 0:
				(a[i], a[l]) = (a[l], a[i])
				l += 1
			else:
				(a[i], a[l - k]) = (a[l - k], a[i])
				break
	print(''.join(a))


import sys
input = sys.stdin.readline
out = sys.stdout

def main():
	q = int(input())
	for _ in range(q):
		(n, k) = map(int, input().split())
		s = list(input().strip())
		su = 0
		zer = 0
		cur_pos = 0
		pos_to_slice = 0
		for i in range(n):
			if s[i] == '0':
				su = i - zer
				if k - su < 0:
					(s[i - k], s[i]) = (s[i], s[i - k])
				else:
					(s[i - su], s[i]) = (s[i], s[i - su])
				cur_pos += 1
				k -= su
				zer += 1
				if k < 0:
					pos_to_slice = i
					break
		if k > 0:
			out.write(''.join((k for k in s[:pos_to_slice])))
			out.write(''.join((k for k in s[pos_to_slice:])) + '\n')
		else:
			out.write(''.join((k for k in s)) + '\n')
main()


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	bs = sys.stdin.readline().split()[0]
	fo = -1
	tmp = []
	tmp3 = []
	kk = 0
	for i in range(len(bs)):
		if bs[i] == '1':
			if fo == -1:
				fo = i
		elif fo != -1:
			tmp.append(i)
		tmp3.append(bs[i])
	j = 0
	while j < len(tmp):
		kk += tmp[j] - fo
		tmp3[fo] = '0'
		tmp3[tmp[j]] = '1'
		if kk >= k:
			tmp3[fo] = '1'
			tmp3[fo + kk - k] = '0'
			break
		j += 1
		fo += 1
	for x in tmp3:
		print(x, end='')
	print()


t = int(input())
while t:
	(n, k) = map(int, input().split())
	s = list(input())
	if k > 0 and set(s) != {'0'}:
		j = s.index('1')
		c = 0
		for i in range(j, n):
			if s[i] == '0':
				if k >= c:
					s[j] = '0'
					j += 1
					s[i] = '1'
					k -= c
				else:
					s[i] = '1'
					s[i - k] = '0'
					k = 0
				if k == 0:
					break
			else:
				c = c + 1
	print(''.join(s))
	t -= 1


n = int(input())
for _ in range(n):
	(m, k) = list(map(int, input().split(' ')))
	st = list(input())
	j = 0
	i = 0
	temp = 0
	new_st = st
	all_ziro = [i for (i, val) in enumerate(st) if val == '0']
	for i in all_ziro:
		j += i - temp
		if j <= k:
			(st[i], st[temp]) = (st[temp], st[i])
			temp += 1
			if j == k:
				break
		elif j > k:
			temp += j - k
			(st[i], st[temp]) = (st[temp], st[i])
			break
	print(''.join(st))


from collections import deque
import sys
import math

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def stli():
	return [i for i in input().rstrip('\n').split(' ')]

def l2():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(int(input())):
	(n, k) = li()
	l = l2()
	zeros = deque()
	for i in range(len(l)):
		if l[i] == 0:
			zeros.append(i)
	ans = []
	for i in range(len(l)):
		if l[i] == 0:
			if len(zeros):
				zeros.popleft()
		elif k and len(zeros):
			if k > zeros[0] - i:
				l[i] = 0
				k -= zeros[0] - i
			else:
				l[zeros[0] - k] = 0
				k = 0
			l[zeros[0]] = 1
			zeros.popleft()
		ans.append(l[i])
	print(*ans, sep='')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	s_list = list(s)
	idx = 0
	while idx < len(s) and s[idx] == '0':
		idx += 1
	ones = 0
	k_counter = 0
	k_counter_idx = -1
	for i in range(len(s)):
		if s_list[i] == '0':
			if ones > 0:
				k_counter += ones
				k_counter_idx = i
		else:
			ones += 1
		if k_counter >= k:
			break
	if k_counter < k:
		print('0' * s.count('0') + '1' * s.count('1'))
	else:
		missed = k_counter - k
		aligned = ones - missed
		suffix = '1' * missed + '0' + '1' * aligned + ''.join(s_list[k_counter_idx + 1:])
		print('0' * (len(s) - len(suffix)) + suffix)


n = int(input())
for gi in range(0, n):
	o = input().rstrip().split(' ')
	s = input().rstrip()
	x = list(s)
	k = int(o[1])
	N = 0
	one = 0
	for i in range(0, len(x)):
		if x[i] == '1':
			one += 1
		elif k >= one:
			k = k - one
			temp = x[i - one]
			x[i - one] = x[i]
			x[i] = temp
		else:
			temp = x[i - k]
			x[i - k] = x[i]
			x[i] = temp
			k = 0
			break
	print(''.join(x))


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	s = input().strip()
	i = 0
	arr = []
	while i < n:
		if s[i] == '0':
			arr.append(0)
			i += 1
		else:
			j = i + 1
			cc = 1
			while j < len(s) and s[i] == s[j]:
				j += 1
				cc += 1
			arr.append(cc)
			i = j
	steps = k
	ans = ''
	ind = 0
	while ind < n:
		if s[ind] == '0':
			print('0', end='')
			ind += 1
		else:
			break
	lul = 0
	stk = []
	for i in range(ind, len(arr)):
		if arr[i] == 0 and len(stk) > 0:
			possible = min(steps, stk[-1])
			bache = stk[-1] - possible
			steps -= possible
			if bache == 0:
				print('0', end='')
			else:
				print('1' * bache, end='')
				print('0', end='')
				stk[-1] = possible
		elif len(stk) > 0:
			stk[-1] += arr[i]
		else:
			stk.append(arr[i])
	for i in range(len(stk)):
		if stk[i] > 0:
			print('1' * stk[i], end='')
		else:
			print('0' * stk[i], end='')
	print()


q = int(input())
for _ in range(q):
	(n, k) = [int(x) for x in input().split()]
	a_ = input()
	a = []
	zero_ind = []
	r = 0
	for i in range(n):
		a += [int(a_[i])]
		if a_[i] == '0':
			zero_ind += [i]
	for i in range(len(zero_ind)):
		r += zero_ind[i] - i
	if r <= k:
		a.sort()
	else:
		p = 0
		while k > 0:
			if zero_ind[p] == p:
				p += 1
			elif zero_ind[p] > p and zero_ind[p] - p <= k:
				a[p] = 0
				a[zero_ind[p]] = 1
				k -= zero_ind[p] - p
				p += 1
			else:
				a[zero_ind[p]] = 1
				a[zero_ind[p] - k] = 0
				k = 0
	print(''.join((str(i) for i in a)))


from sys import stdin, stdout
from os import path
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
for _ in range(int(stdin.readline())):
	(a, b) = map(int, stdin.readline().strip().split())
	amr = stdin.readline()
	out = ['1'] * a
	cnt = 0
	for i in range(len(amr)):
		if amr[i] == '0':
			mn = min(i - cnt, b)
			b -= mn
			out[i - mn] = '0'
			cnt += 1
	stdout.write(''.join(out) + '\n')


q = int(input())
for query in range(q):
	(n, k) = [int(x) for x in input().split(' ')]
	s = input()
	pos = []
	for i in range(n):
		if s[i] == '0':
			pos.append(i)
	moves = 0
	i = 0
	while i < len(pos) and moves < k:
		m = min(pos[i] - i, k - moves)
		pos[i] -= m
		moves += m
		i += 1
	ans = ['1'] * n
	for j in pos:
		ans[j] = '0'
	print(''.join(ans))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	t = list(map(int, input()))
	l = []
	for i in range(n):
		if t[i] == 0:
			l.append(i)
	p = 0
	top = k
	res = [1] * n
	for i in range(len(l)):
		ind = i
		i = l[i]
		if top - (i - p) >= 0:
			l[ind] = p
			top -= i - p
			p += 1
		else:
			new = i - top
			l[ind] = new
			break
	for i in l:
		res[i] = 0
	print(*res, sep='')


from sys import stdin
from collections import defaultdict

def get_position():
	pos = []
	for i in range(n):
		if string[i] == '0':
			pos.append(i)
	return pos

def swap(first, second):
	(string[first], string[second]) = (string[second], string[first])
q = int(stdin.readline().strip())
for _ in range(q):
	(n, k) = list(map(int, stdin.readline().split()))
	string = list(stdin.readline().strip())
	pos = get_position()
	i = 0
	offset = 0
	while k > 0 and i < len(pos):
		if pos[i] - offset <= k:
			if string[offset] == '1':
				k -= pos[i] - offset
			swap(offset, pos[i])
			offset += 1
			i += 1
		else:
			swap(pos[i], pos[i] - k)
			k = 0
			break
	print(''.join(string))


import statistics
import math
import datetime
import collections
import bisect
import heapq
__author__ = 'Zumrat Kochshegulov'
__contact__ = 'topcoderkz[at]gmail.com'

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		s = input()
		ans = list('1' * n)
		last_zero = 0
		for i in range(n):
			if s[i] == '0':
				x = min(m, i - last_zero)
				ans[i - x] = '0'
				m -= x
				last_zero += 1
		print(''.join(ans))
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = [int(i) for i in input()]
	bckt = []
	for i in range(n):
		if not s[i]:
			bckt.append(i)
	sh = 0
	ind = 0
	for i in bckt:
		if i - sh <= k:
			k -= i - sh
			sh += 1
			ind = i
	s = sorted(s[:ind + 1]) + s[ind + 1:]
	for i in range(ind + 1, n):
		if not s[i]:
			s = s[:i - k] + sorted(s[i - k:i + 1]) + s[i + 1:]
			break
	print(''.join(map(str, s)))


t = int(input())
for it in range(t):
	(n, k) = map(int, input().split())
	a = list(input())
	o = 0
	for i in range(n):
		if a[i] == '1':
			o += 1
		elif k >= o:
			(a[i], a[i - o]) = (a[i - o], a[i])
			k -= o
		else:
			(a[i], a[i - k]) = (a[i - k], a[i])
			break
	print(''.join(a))


l1 = []
l2 = []
q = int(input())
for i in range(q):
	e = list(map(int, input().strip().split()))
	a = list(str(input()))
	l1.append(e)
	l2.append(a)
for j in range(len(l2)):
	w = ['1'] * len(l2[j])
	t = 0
	k = ''
	for i in range(len(l2[j])):
		if l2[j][i] == '0' and l1[j][1] >= i - t:
			w[t] = '0'
			l1[j][1] = l1[j][1] - i + t
			t = t + 1
		elif l2[j][i] == '0' and i - t >= l1[j][1]:
			w[i - l1[j][1]] = '0'
			l1[j][1] = 0
	print(k.join(w))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s = [x for x in s]
	ch = 0
	t = 0
	j = True
	for i in range(len(s)):
		if s[i] == '0':
			if ch + i - t > k:
				s[i] = '1'
				s[i - k + ch] = '0'
				break
			else:
				s[i] = '1'
				s[t] = '0'
				ch += i - t
			t += 1
	print(''.join(s))


def f(s, k):
	s = list(s)
	i = 1
	while i < len(s) and k > 0:
		if s[i - 1] == '1' and s[i] == '0':
			(s[i - 1], s[i]) = (s[i], s[i - 1])
			k -= 1
			if i > 1:
				i -= 1
		else:
			i += 1
	return ''.join(s)

def g(s, k):
	z = []
	for (i, n) in enumerate(s):
		if n == '0':
			z.append(i)
	for i in range(len(z)):
		prev = -1
		if i > 0:
			prev = z[i - 1]
		dist = min(k, z[i], z[i] - prev - 1)
		z[i] -= dist
		assert z[i] >= 0
		k -= dist
		if k == 0:
			break
	out = ['1'] * len(s)
	for i in z:
		out[i] = '0'
	return ''.join(out)
assert g('11011010', 5) == '01011110'
assert g('111011001', 13) == '000111111'
assert g('1111100', 11) == '0011111'
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = input()
	ans = g(s, k)
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = list(input().strip())
	last0 = -1
	for i in range(n):
		if s[i] == '0':
			s[i] = '1'
			v = i - last0 - 1
			if k > v:
				k -= v
				s[last0 + 1] = '0'
				last0 += 1
			else:
				s[i - k] = '0'
				break
	print(*s, sep='')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	z = []
	for i in range(n):
		if s[i] == '0':
			z.append(i)
	x = 0
	j = 0
	ans = ''
	while j < len(z):
		if x + z[j] - j <= k:
			x += z[j] - j
		else:
			break
		j += 1
	if j == len(z):
		print('0' * len(z) + '1' * (n - len(z)))
	else:
		t = '0' * j + '1' * (z[j] - j - (k - x)) + '0' + '1' * (k - x) + s[z[j] + 1:]
		print(t)


tc = int(input())
for _ in range(tc):
	(n, k) = map(int, input().split())
	s = input()
	s = list(s)
	ans = ['1'] * n
	t = 0
	for i in range(n):
		if s[i] == '0':
			temp = min(k, i - t)
			k = k - temp
			ans[i - temp] = '0'
			t += 1
	print(''.join(ans))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	s = list(s)
	lol = 0
	ans = []
	for i in range(n):
		if s[i] == '1':
			lol += 1
		elif s[i] == '0':
			if k >= lol:
				k -= lol
				s[i] = -1
				ans.append('0')
			else:
				for j in range(n):
					if s[j] != -1:
						ans.append(s[j])
						s[j] = -1
				(ans[i], ans[i - k]) = (ans[i - k], ans[i])
				k = 0
	for i in range(n):
		if s[i] != -1:
			ans.append(s[i])
			s[i] = -1
	print(''.join(ans))


for _ in range(int(input())):
	(n, k) = [int(__) for __ in input().split()]
	s = input()
	l1 = []
	sum_ = 0
	index_ = 0
	for i in range(n):
		if s[i] == '0':
			sum_ += i - len(l1)
			l1.append(i - len(l1))
			index_ = i
		if sum_ > k:
			break
	ans = ''
	if sum_ < k:
		ans = '0' * len(l1) + '1' * (n - len(l1))
	else:
		ans = '0' * (len(l1) - 1) + (sum_ - k) * '1' + '0'
		ans += '1' * (index_ + 1 - len(ans))
		ans += s[index_ + 1:]
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(str(input()))
	p = -1
	for i in range(n):
		if s[i] == '1' and p == -1:
			p = i
		if s[i] == '0' and p != -1:
			while i - p > k:
				p = p + 1
			if p >= i:
				break
			s[i] = '1'
			s[p] = '0'
			k = k - (i - p)
			p = p + 1
			if k <= 0:
				break
	for i in range(n):
		print(s[i], end='')
	print()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(n, k) = ria()
		a = list(rs())
		ns = ''
		c = 0
		ans = ['1'] * n
		for i in range(n):
			if a[i] == '0':
				dist = min(k, i - c)
				ans[i - dist] = '0'
				c += 1
				k -= dist
		print(ns.join(ans))
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


q = int(input())
for i in range(q):
	[n, k] = map(int, input().split())
	b = list(input())
	bound = 0
	prevV = 0
	while k > 0:
		ci = prevV
		while ci < n and b[ci] == '1':
			ci += 1
		if ci >= n:
			break
		else:
			l = ci - bound
			if k >= l:
				(b[ci], b[bound]) = (b[bound], b[ci])
				k -= l
			else:
				(b[ci], b[ci - k]) = (b[ci - k], b[ci])
				k = 0
			prevV = ci + 1
		bound += 1
	print(''.join(b))


def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return [str(x) for x in stdin.readline().split('')]
from sys import stdin, stdout
from collections import deque
from bisect import insort_right
from time import perf_counter
for i in range(int(input())):
	(n, k) = arr_inp(1)
	(s, one) = (list(input()), deque([]))
	for i in range(n):
		if int(s[i]):
			one.append(i)
		else:
			if one == deque([]):
				continue
			s[i] = '1'
			if i - one[0] <= k:
				s[one[0]] = '0'
				k -= i - one.popleft()
				one.append(i)
			else:
				s[i - k] = '0'
				break
	print(''.join(s))


def answer(A, n, k):
	count = 0
	index = 0
	for i in range(n):
		if k == 0:
			break
		if A[i] == '0':
			if k - count >= 0:
				(A[index], A[i]) = (A[i], A[index])
				index += 1
				k -= count
			else:
				(A[i], A[i - k]) = (A[i - k], A[i])
				k = 0
		else:
			count += 1
	return ''.join(A)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	A = list(input())
	print(answer(A, n, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	zer = []
	for i in range(len(s)):
		if s[i] == '0':
			zer.append(i)
	one = zer[:]
	x = 0
	y = 0
	sw = -1
	v = 0
	for i in range(len(zer)):
		if k == 0:
			break
		if sw == y:
			v += 1
			one[i] -= v
		x = zer[i]
		y = one[i]
		sw = min(y, k)
		(s[x], s[x - sw]) = (s[x - sw], s[x])
		k -= sw
	print(''.join(s))


q = int(input())
for i in range(q):
	(n, k) = [int(s) for s in input().split()]
	s = input()
	preLen = 0
	step = 0
	unfinished = 0
	for i in range(n):
		if s[i] == '0':
			if k >= step:
				k -= step
				preLen += 1
			else:
				unfinished = 1
				break
		else:
			step += 1
	if unfinished:
		ans = '0' * preLen + '1' * (step - k) + '0' + '1' * k + s[preLen + step + 1:]
	else:
		ans = '0' * preLen + '1' * (n - preLen)
	print(ans)


for _ in range(int(input())):
	(n, k) = [int(j) for j in input().split()]
	bs = input()
	l1 = []
	c = 0
	for i in range(n):
		if bs[i] == '1':
			c += 1
		else:
			l1.append((c, i))
	s = sum([i[0] for i in l1])
	if s <= k:
		no_of_0s = bs.count('0')
		print(no_of_0s * '0' + '1' * (n - no_of_0s))
	else:
		l = ['1' for i in range(n)]
		cnt = 0
		for i in l1:
			if i[0] <= k:
				l[cnt] = '0'
				cnt += 1
				k -= i[0]
			elif k > 0:
				l[i[1] - k] = '0'
				k -= i[0]
			else:
				l[i[1]] = '0'
		print(''.join(l))


from sys import stdin, stdout

def ip():
	return [int(i) for i in stdin.readline().split()]

def sp():
	return [str(i) for i in stdin.readline().split()]

def solve():
	(n, k) = ip()
	A = list(str(input()))
	s = []
	cnt = 0
	for i in range(len(A)):
		if A[i] == '1':
			cnt += 1
		elif k >= cnt:
			s.append('0')
			k -= cnt
		else:
			for _ in range(cnt - k):
				s.append('1')
			s.append('0')
			for _ in range(n - (len(s) + len(A[i + 1:]))):
				s.append('1')
			s += A[i + 1:]
			return ''.join(s)
	for i in range(n - len(s)):
		s.append('1')
	return ''.join(s)
t = int(input())
for _ in range(t):
	print(solve())


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	w = input()
	l = []
	c = 0
	ans = ''
	su = 0
	f = 0
	for j in range(a):
		if w[j] == '1':
			c += 1
		else:
			l.append(c)
			su += c
			f += 1
	if f == 0:
		print(w)
		continue
	elif su <= b:
		ans = '0' * f + '1' * l[f - 1]
	else:
		for i in range(len(l)):
			if b == 0:
				break
			if l[i] <= b:
				ans += '0'
				b -= l[i]
				if i == len(l) - 1 or b == 0:
					ans += '1' * l[i]
			else:
				ans += '1' * (l[i] - b) + '0' + '1' * b
				b = 0
	ans += w[len(ans):]
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().strip().split())
	s = input().strip()
	ans = ''
	count = 0
	for i in range(n):
		if s[i] == '1':
			count += 1
		elif k >= count:
			ans += '0'
			k -= count
		else:
			x = count - k
			ans += '1' * x + '0' + '1' * k
			ans += s[i + 1:]
			break
		if i == n - 1 and count:
			ans += '1' * count
	print(ans)


def minimize(s, n, k):
	s = list(s)
	fin = False
	cnt = 0
	i = 0
	res = ''
	while i < n:
		if s[i] == '1':
			cnt += 1
		elif cnt < k:
			k -= cnt
			res += '0'
		else:
			fin = True
			for j in range(cnt - k):
				res += '1'
			res += '0'
			for j in range(k):
				res += '1'
			res += ''.join(s[i + 1:])
			break
		i += 1
	if not fin:
		for i in range(cnt):
			res += '1'
			i += 1
	return res
q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	s = input()
	res = minimize(s, n, k)
	print(res)


for _ in range(int(input())):
	(N, k) = map(int, input().split())
	string = input()
	s = [i for i in string]
	output = ''
	start = -1
	length = len(s)
	for i in range(length):
		if s[i] == '1':
			start = i
			break
	if start == -1:
		print(string)
		continue
	for i in range(start + 1, N):
		if s[i] == '1':
			continue
		if s[i] == '0':
			if i - start > k:
				(s[i - k], s[i]) = (s[i], s[i - k])
				break
			else:
				(s[start], s[i]) = (s[i], s[start])
				k -= i - start
			start += 1
	output = ''.join(s)
	print(output)


q = int(input())
for q0 in range(q):
	(length, m) = map(int, input().split(' '))
	s = input()
	l = list(s)
	index = [-1]
	for i in range(0, len(l)):
		if l[i] == '0':
			index.append(i)
	for i in range(1, len(index)):
		x = min(index[i] - index[i - 1] - 1, m)
		m -= x
		(l[index[i]], l[index[i] - x]) = (l[index[i] - x], l[index[i]])
		index[i] -= x
		if m == 0:
			break
	for i in l:
		print(i, end='')
	print('')


def main():
	(n, k) = map(int, input().split())
	a = list(str(input()))
	start = 0
	for i in range(len(a)):
		if a[i] == '0':
			if k - (i - start) >= 0:
				k -= i - start
				(a[i], a[start]) = (a[start], a[i])
				start += 1
			elif a[i - k] == '1':
				(a[i - k], a[i]) = (a[i], a[i - k])
				k -= k
				break
	print(''.join(a))
t = int(input())
while t:
	main()
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	ptr = -1
	for i in range(n):
		if s[i] == '1' and ptr == -1:
			ptr = i
		if s[i] == '0' and ptr != -1:
			if i - ptr > k:
				ptr += i - ptr - k
			s[ptr] = '0'
			s[i] = '1'
			k -= i - ptr
			if k == 0:
				break
			ptr += 1
	print(''.join(s))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	b = list(input().strip())
	first_one = -1
	fwd_pnt = 0
	op = 0
	while fwd_pnt < n and op <= k:
		if b[fwd_pnt] == '1' and first_one == -1:
			first_one = fwd_pnt
		elif b[fwd_pnt] == '1':
			pass
		elif b[fwd_pnt] == '0':
			if first_one != -1:
				if fwd_pnt - first_one <= k - op:
					(b[first_one], b[fwd_pnt]) = (b[fwd_pnt], b[first_one])
					op += fwd_pnt - first_one
					first_one += 1
				else:
					(b[fwd_pnt - k + op], b[fwd_pnt]) = (b[fwd_pnt], b[fwd_pnt - k + op])
					break
			else:
				pass
		fwd_pnt += 1
	print(''.join(b))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	temp = ['1'] * n
	cap = k
	cnt_z = 0
	for i in range(n):
		if s[i] == '0':
			if cap > 0:
				z = min(i - cnt_z, cap)
				if cap - z > 0:
					temp[cnt_z] = '0'
				else:
					temp[i - cap] = '0'
				cap -= z
				cnt_z += 1
			else:
				temp[i] = s[i]
		else:
			temp[i] = s[i]
	print(''.join(temp))


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
for _ in range(it()):
	(n, k) = mp()
	l = list(input())
	v = ['1'] * n
	t = 0
	for i in range(n):
		if l[i] == '0':
			x = min(k, i - t)
			k -= x
			v[i - x] = '0'
			t += 1
	print(''.join(v))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, k) = LI()
		s = S()
		c = s[0]
		d = 1
		a = []
		if c == '1':
			a.append(0)
		for t in s[1:]:
			if t == c:
				d += 1
			else:
				a.append(d)
				d = 1
				c = t
		a.append(d)
		l = len(a)
		u = 0
		for i in range(2, l):
			if i % 2 == 1:
				a[i] += a[i - 2]
				a[i - 2] = 0
				continue
			t = a[i]
			u = a[i - 1]
			if t * u <= k:
				a[i] = 0
				a[0] += t
				k -= t * u
				if k == 0:
					break
			else:
				v = k // u
				a[i] -= v
				a[0] += v
				w = k % u
				a[i] -= 1
				a[i - 1:i] = [u - w, 1, w]
				break
		rr.append(JA([str(i % 2) * c for (i, c) in enumerate(a)], ''))
	return JA(rr, '\n')
print(main())


m = int(input())
for j in range(m):
	(n, k) = map(int, input().split())
	a = input()
	b = []
	t = 0
	c = list(a)
	s = 0
	for i in range(n):
		if a[i] == '0':
			if i - s <= k:
				c[s] = '0'
				k -= i - s
			else:
				if k > 0:
					c[i - k] = '0'
					c[i] = '1'
				break
			s += 1
			if i != t:
				c[i] = '1'
			t += 1
	print(''.join(c))


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ans = list(input())
	s = ['1'] * n
	flag = 0
	for i in range(n):
		if ans[i] == '0':
			a = min(k, i - flag)
			k -= a
			s[i - a] = '0'
			flag += 1
	print(''.join(s))


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = input()
	ans = []
	one = 0
	for i in range(n):
		x = s[i]
		if x == '1':
			one += 1
		elif k >= one:
			ans.append('0')
			k -= one
		else:
			ans.append('1' * (one - k))
			ans.append('0')
			ans.append('1' * k)
			ans.extend(s[i + 1:])
			break
	else:
		ans.extend('1' * one)
	print(''.join(ans))


import sys
from collections import Counter

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, K) = MAP()
	S = input()
	ST = []
	i = 0
	for j in range(N):
		if S[j] == '0':
			ST.append((i, j))
			i += 1
	ans = ['1'] * N
	cnt = K
	for (s, t) in ST:
		dist = t - s
		if dist <= cnt:
			cnt -= dist
			ans[s] = '0'
		else:
			ans[s + dist - cnt] = '0'
			cnt = 0
	print(''.join(ans))


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, k) = value()
	s = list(input())
	indices_of_0 = [i for i in range(n) if s[i] == '0']
	upto = 0
	for i in indices_of_0:
		j = max(upto, i - k)
		k -= i - j
		(s[i], s[j]) = (s[j], s[i])
		upto = j + 1
	print(*s, sep='')


import sys
q = int(sys.stdin.readline())
for _ in range(q):
	(n, k) = map(int, sys.stdin.readline().split())
	arr = list(map(int, list(sys.stdin.readline().strip())))
	st = 0
	for i in range(n):
		if k == 0:
			break
		if arr[i] == 0:
			dist = i - st
			temp = arr[i]
			if k >= dist:
				arr[i] = arr[st]
				arr[st] = temp
				k -= dist
				st += 1
			else:
				arr[i] = arr[i - k]
				arr[i - k] = temp
				k = 0
				st += 1
	arr = ''.join(list(map(str, arr)))
	print(arr)


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return fac

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)

def modInverse(a, m):
	m0 = m
	y = 0
	x = 1
	if m == 1:
		return 0
	while a > 1:
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if x < 0:
		x = x + m0
	return x
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	c = sorted(list(s))
	if list(s) == sorted(list(s)):
		print(s)
	else:
		s = list(s)
		pos = 0
		for i in range(0, len(s)):
			if s[i] == '0':
				d = min(k, i - pos)
				k -= d
				(s[i - d], s[i]) = (s[i], s[i - d])
				pos += 1
		print(''.join(s))


t = int(input())
for x in range(t):
	(n, k) = [int(i) for i in input().split()]
	s = list(input())
	moves = 0
	sorted = 0
	for i in range(n):
		if moves >= k:
			break
		if s[i] == '0':
			s[i] = '1'
			if moves + i - sorted <= k:
				s[sorted] = '0'
			else:
				s[i - k + moves] = '0'
			moves += i - sorted
			sorted += 1
	for c in s:
		print(c, end='')
	print()


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	s = list(input())
	min_pos = 0
	for j in range(n):
		if s[j] == '0':
			p = max(j - k, min_pos)
			if k >= j - p:
				k -= j - p
				(s[j], s[p]) = (s[p], s[j])
				min_pos = p + 1
	print(''.join(map(str, s)))


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	s = input()
	cont = 0
	bit = 0
	zeros = []
	for i in range(n):
		if s[i] == '0':
			zeros.append(i)
	for (i, v) in enumerate(zeros):
		if k > v - bit:
			a = v - bit
			k -= a
			print('0', end='')
			bit += 1
		else:
			falta = v - bit - k
			bit += 1
			for x in range(falta):
				print('1', end='')
			print('0', end='')
			for x in range(v - falta - bit + 1):
				print('1', end='')
			v += 1
			while v < n:
				print(s[v], end='')
				v += 1
			break
	else:
		print('1' * (n - len(zeros)), end='')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	zeroes = []
	for i in range(n):
		if s[i] == '0':
			zeroes.append(i)
	s = list(s)
	ind = 0
	le = len(zeroes)
	i = 0
	while i < n:
		if s[i] == '1':
			while ind < le and zeroes[ind] < i:
				ind += 1
			if ind == le:
				break
			a = zeroes[ind]
			if a - i <= k:
				k -= a - i
				(s[i], s[a]) = (s[a], s[i])
				ind += 1
		i += 1
	print(''.join(s))


from sys import stdin, stdout
from math import gcd, sqrt, factorial
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for i in range(I()):
	(n, k) = R()
	a = list(S())
	srt = 0
	for i in range(n):
		if a[i] == '0' and srt == i:
			srt += 1
			continue
		if a[i] == '0' and k:
			cut = i - max(i - k, srt)
			k -= cut
			a[i - cut] = '0'
			a[i] = '1'
			srt += 1
	print(*a, sep='')


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	perm = list((int(x) for x in input()))

	def swap(i, j):
		(perm[i], perm[j]) = (perm[j], perm[i])
	onLeft = 0
	for (i, item) in enumerate(perm):
		if item == 0:
			if k < i - onLeft:
				swap(i - k, i)
				break
			else:
				swap(onLeft, i)
				k -= i - onLeft
				onLeft += 1
	print(''.join(map(str, perm)))


Q = int(input())
Query = []
for _ in range(Q):
	(N, K) = map(int, input().split())
	S = list(input())
	Query.append((N, K, S))
for (N, K, S) in Query:
	zeros = 0
	ans = []
	for i in range(N):
		if S[i] == '0':
			if i - zeros <= K:
				K -= i - zeros
				zeros += 1
			else:
				ans += ['0'] * zeros
				ans += ['1'] * (i - zeros - K)
				ans += ['0']
				ans += ['1'] * K
				last = i
				break
	if not ans:
		ans = sorted(S)
	else:
		for i in range(last + 1, N):
			ans.append(S[i])
	print(''.join(ans))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	w = input()
	l = []
	c = 0
	ans = ''
	su = 0
	f = 0
	for j in range(n):
		if w[j] == '1':
			c += 1
		else:
			l.append(c)
			su += c
			f += 1
	if f == 0:
		print(w)
		continue
	elif su <= k:
		ans = '0' * f + '1' * l[f - 1]
	else:
		for i in range(len(l)):
			if k == 0:
				break
			if l[i] <= k:
				ans += '0'
				k -= l[i]
				if i == len(l) - 1 or k == 0:
					ans += '1' * l[i]
			else:
				ans += '1' * (l[i] - k) + '0' + '1' * k
				k = 0
	ans += w[len(ans):]
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = [*input()]
	t = 0
	ans = ['1'] * n
	for i in range(n):
		if s[i] == '0':
			z = min(k, i - t)
			k -= z
			ans[i - z] = '0'
			t += 1
	print(''.join(ans))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	ind = 0
	for i in range(n):
		if s[i] == '0':
			if i - ind <= k:
				k -= i - ind
				s[i] = '1'
				s[ind] = '0'
				ind += 1
			else:
				s[i] = '1'
				s[i - k] = '0'
				break
	print(''.join(s))


import math
q = int(input())
for i in range(q):
	(n, k) = list(map(int, input().split()))
	s = input()
	l = []
	count = 0
	s = list(s)
	le = len(s)
	for i in range(le):
		if s[i] == '0':
			l.append(i)
			count += 1
	l.reverse()
	for i in range(le):
		if count == 0:
			break
		ind = l.pop()
		count -= 1
		dist = ind - i
		if dist > k:
			s[ind] = '1'
			s[ind - k] = '0'
			break
		else:
			k -= dist
			s[ind] = '1'
			s[i] = '0'
	s = ''.join(s)
	print(s)


q = int(input())
i = 1
while i <= q:
	[n, k] = list(map(int, input().split()))
	s = input()
	ans = [-1 for j in range(n)]
	ones = 0
	used = 0
	modified = 0
	for (ind, j) in enumerate(s):
		if j == '1':
			ones += 1
		elif j == '0':
			if ones == 0:
				ans[ind] = 0
				modified += 1
			elif k - used >= ones:
				ans[ind - ones] = 0
				modified += 1
				used += ones
			else:
				ans[ind - (k - used)] = 0
				used = k
				modified += 1
				break
	passed = 0
	for (ind, j) in enumerate(ans):
		if s[ind] == '0':
			passed += 1
		if j == -1 and passed > modified and (s[ind] == '0'):
			j = 0
		elif j == -1:
			j = 1
		print(j, end='')
	print()
	i += 1


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	b = input()
	a = []
	p = 0
	q = 0
	for j in range(n):
		if b[j] == '0':
			a.append(j - p)
			p += 1
		else:
			q += 1
	l = 0
	su = 0
	f = []
	for d in range(len(a)):
		if k > a[d]:
			k += -a[d]
			a[d] = 0
		else:
			a[d] += -k
			k = 0
		if d < len(a) - 1:
			l += a[d]
			a[d + 1] -= l
		su += a[d]
		f += ['1'] * a[d]
		f += ['0'] * 1
	f += ['1'] * (q - su)
	s = ''.join(f)
	print(s)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = input()
	ls = ''
	p = [0 for i in range(n)]
	step = 0
	f = 0
	for i in range(n):
		var = int(s[i])
		p[i] = p[i - 1] + var
		if var == 0:
			if m >= p[i]:
				step += 1
				m -= p[i]
			else:
				ls += '0' * step + '1' * (i + 1 - step) + s[i + 1:]
				ls = list(ls)
				ls[i - m] = '0'
				print(''.join(ls))
				f = 1
				break
	if f == 0:
		print('0' * step + '1' * (n - step))


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from collections import defaultdict as dd
from math import gcd
(t,) = I()
while t:
	t -= 1
	(n, k) = I()
	s = list(input())
	os = [0] * (n + 1)
	z = []
	for i in range(n):
		os[i] = s[i] == '1'
		os[i] += os[i - 1]
		if s[i] == '0':
			z.append(i)
	ans = ['1'] * n
	for i in z:
		ones = os[i]
		m = min(ones, k)
		k -= m
		ans[i - m] = '0'
	print(''.join(ans))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(input())
	pos = 0
	for (idx, i) in enumerate(l):
		if i == '0':
			if idx - pos < k:
				(l[pos], l[idx]) = (l[idx], l[pos])
				k -= idx - pos
			else:
				l[idx - k] = '0'
				l[idx] = '1'
				break
			pos += 1
	print(''.join(l))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	s = []
	for i in input():
		s.append(int(i))
	one = 0
	minpoz = 0
	for i in range(n):
		if s[i] == 1:
			one += 1
			one = min(one, k)
		else:
			minpoz = max(minpoz, i - k)
			while minpoz < i and s[minpoz] != 1:
				minpoz += 1
			if s[minpoz] == 1:
				(s[minpoz], s[i]) = (s[i], s[minpoz])
				k -= i - minpoz
		if k == 0:
			break
	s = list(map(str, s))
	print(''.join(s))


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = input()
	b = []
	count = 0
	for i in range(n):
		if a[i] == '0':
			b.append(i)
			count += 1
	for i in range(count):
		if b[i] - i < m:
			m -= b[i] - i
			b[i] = i
		else:
			b[i] = b[i] - m
			break
	visited = [1 for i in range(n)]
	for i in range(count):
		visited[b[i]] = 0
	for i in range(n):
		print(visited[i], end='')
	print()


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
for _ in range(INI()):
	(n, k) = INL()
	S = list(INS())
	i = -1
	X = []
	for _ in range(n):
		if S[_] == '0':
			if _ - i - 1 <= k:
				X.append(i + 1)
				k -= _ - (i + 1)
				i = i + 1
			else:
				X.append(_ - k)
				k = 0
	i = 0
	x = len(X)
	for _ in range(n):
		if i != x and _ == X[i]:
			print('0', end='')
			i += 1
		else:
			print('1', end='')
	print()


from collections import deque
for __ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	ar = list(map(int, input()))
	lol = deque([])
	for i in range(n):
		if ar[i] == 0:
			lol.append(i)
	i = 0
	while lol and len(lol) > i and (lol[i] == i):
		i += 1
	num = i
	for __ in range(i):
		lol.popleft()
	while lol and k > 0:
		x = lol[0]
		if k >= x - num:
			k -= x
			k += num
			lol.popleft()
			i += 1
			num += 1
		else:
			break
	ans = []
	for j in range(i):
		ans.append(0)
	if lol:
		lol[0] -= k
	for j in range(i, n):
		if lol and j == lol[0]:
			ans.append(0)
			lol.popleft()
		else:
			ans.append(1)
	print(''.join(map(str, ans)))


import random

def get_many_ints():
	return map(int, input().split())

def get_int():
	return int(input())

def get_int_list():
	return list(get_many_ints)

def prog():
	(N, k) = get_many_ints()
	t = list(input())
	b = 0
	while b < N and t[b] == '0':
		b += 1
	e = b + 1
	while e < N and t[e] == '1':
		e += 1
	while e < N and k > 0:
		if k < e - b:
			b = e - k
		(t[b], t[e]) = (t[e], t[b])
		k -= e - b
		b += 1
		while e < N and t[e] == '1':
			e += 1
	print(''.join(t))
q = get_int()
for _ in range(q):
	prog()


q = int(input())
ans = []
for j in range(q):
	(n, k) = map(int, input().split(' '))
	mass = list(input())
	K = k
	t = 0
	for i in range(n - 1):
		if mass[i] > mass[i + 1]:
			if t + 1 < K:
				mass[i - t] = '0'
				mass[i + 1] = '1'
				K = K - t - 1
			else:
				mass[i - K + 1] = '0'
				mass[i + 1] = '1'
				K = 0
				break
		elif mass[i] == '1' and mass[i + 1] == '1':
			t += 1
	ans.append(''.join(mass))
for j in range(q):
	print(ans[j])


import sys
inp = sys.stdin.read().splitlines()
inp.reverse()
q = int(inp.pop())
results = []
import traceback
try:
	for __ in range(q):
		(n, k) = map(int, inp.pop().split())
		s = inp.pop()
		ones = []
		i = 0
		while i < n:
			while i < n and s[i] == '0':
				i += 1
			start = i
			end = None
			while i < n and s[i] == '1':
				i += 1
				end = i
			if end is not None:
				ones.append([start, end - 1])
		ones.reverse()
		while k and ones:
			cur = ones.pop()
			if cur[1] == n - 1:
				ones.append(cur)
				k = 0
			if k >= cur[1] - cur[0] + 1:
				k -= cur[1] - cur[0] + 1
				cur[0] += 1
				cur[1] += 1
				if ones and ones[-1][0] == cur[1] + 1:
					ones[-1][0] = cur[0]
				else:
					ones.append(cur)
			else:
				(cur_left, cur_right) = ([cur[0], cur[1] - k], [cur[1] + 1 - k + 1, cur[1] + 1])
				ones.append(cur_right)
				ones.append(cur_left)
				k = 0
		ones.reverse()
		result = ['0'] * n
		for cur in ones:
			for i in range(cur[0], cur[1] + 1):
				result[i] = '1'
		results.append(''.join(result))
except Exception as e:
	print(traceback.format_exc())
for result in results:
	print(result)


opaaaa = int(input())
for _ in range(opaaaa):
	MUSOR = []
	(n, k) = map(int, input().split())
	STROKA = input().strip()
	for _ in range(len(STROKA)):
		if STROKA[_] == '0':
			MUSOR.append(_)
	bilo = dict()
	pos = 0
	for i in range(len(MUSOR)):
		if k >= MUSOR[i] - pos:
			k -= MUSOR[i] - pos
			MUSOR[i] = pos
			bilo[pos] = MUSOR[i]
			pos += 1
		elif k > 0:
			bilo[MUSOR[i] - k] = MUSOR[i] - k
			MUSOR[i] -= k
			k = 0
		else:
			bilo[MUSOR[i]] = MUSOR[i]
	pos = 0
	OTVET = ''
	for i in range(len(STROKA)):
		if i in bilo:
			print('0', end='')
		else:
			print('1', end='')
	print()


import sys

def solve(s, k):
	chrs = [c for c in s]
	prev_0 = -1
	for i in range(len(chrs)):
		if k == 0:
			break
		if chrs[i] == '0':
			move = min(i - prev_0 - 1, k)
			k -= move
			chrs[i] = chrs[i - move]
			chrs[i - move] = '0'
			prev_0 = i - move
	return ''.join(chrs)
t = int(input().strip())
for i in range(t):
	vs = [int(v) for v in input().strip().split(' ')]
	(n, k) = (vs[0], vs[1])
	s = input().strip()
	print(solve(s, k))


def minimize(n, k, s):
	zeros_kicked = 0
	for i in range(n):
		if s[i] == '0':
			if i - zeros_kicked >= k:
				(s[i], s[i - k]) = (s[i - k], s[i])
				break
			else:
				(s[i], s[zeros_kicked]) = (s[zeros_kicked], s[i])
				k = k - i + zeros_kicked
				zeros_kicked += 1
	ans = ''.join(s)
	return ans
q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	s = list(input())
	print(minimize(n, k, s))


ct = int(input())
for c in range(ct):
	(n, k) = map(int, input().split())
	s = [i for i in input()]
	melhor = 0
	for i in range(n):
		if s[i] == '0':
			s[i] = '-1'
			melhor += 1
		else:
			break
	for i in range(n):
		if s[i] == '0':
			if k == 0:
				break
			nova = max(melhor, i - k)
			(s[i], s[nova]) = ('1', '-1')
			k -= i - nova
			melhor += 1
		if k == 0:
			break
	print(''.join(s).replace('-1', '0'))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s = input()
	prefix = 0
	ans = []
	i = 0
	while k > 0 and i < n:
		if s[i] == '1':
			prefix += 1
		elif k >= prefix:
			ans.append('0')
			k -= prefix
		else:
			left_ones = prefix - k
			j = 0
			while j < left_ones:
				ans.append('1')
				j += 1
			prefix = k
			k = 0
			ans.append('0')
		i += 1
	j = 0
	while j < prefix:
		ans.append('1')
		j += 1
	while i < n:
		ans.append(s[i])
		i += 1
	for i in range(n):
		print(ans[i], end='')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = input()
	a = list(a)
	c = 0
	for i in range(n):
		if a[i] == '0':
			k = k - i + c
			if k >= 0:
				(a[i], a[c]) = (a[c], a[i])
				c = c + 1
			else:
				k = k + i - c
				(a[i], a[i - k]) = (a[i - k], a[i])
				break
	for i in range(n):
		print(a[i], end='')
	print()


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	pref = []
	s = [i for i in input()]
	cur = 0
	for i in range(n):
		if i == 0 and s[i] == '1':
			pref.append(1)
		elif i == 0 and s[i] == '0':
			pref.append(0)
		elif s[i] == '1':
			pref.append(1 + pref[-1])
		else:
			pref.append(pref[-1])
	for i in range(n):
		if k == 0:
			break
		elif s[i] == '0' and pref[i] <= k:
			(s[i], s[i - pref[i]]) = (s[i - pref[i]], s[i])
			k -= pref[i]
		elif s[i] == '0' and pref[i] > k:
			(s[i], s[i - k]) = (s[i - k], s[i])
			k = 0
	print(''.join(s))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = str(input())
	l = list(s)
	cone = 0
	c = 0
	for i in range(n):
		if l[i] == '1':
			cone += 1
		elif k - cone >= 0:
			temp = l[c]
			l[c] = l[i]
			l[i] = temp
			c += 1
			k -= cone
		else:
			temp = l[cone - k + c]
			l[cone - k + c] = l[i]
			l[i] = temp
			k = 0
			c += 1
			break
	for i in l:
		print(i, end='')
	print()


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ls = list((int(x) for x in input()))
	ans = []
	i = 0
	cnt = 0
	while i < n:
		if ls[i] == 1:
			cnt += 1
		elif cnt <= k:
			k -= cnt
			ans.append(0)
			ls[i] = 1
		else:
			ls[i - k] = 0
			ls[i] = 1
			break
		if k == 0:
			break
		i += 1
	ans.extend(ls[len(ans):])
	print(''.join((str(x) for x in ans)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = list(input())
	ans = [1] * n
	s = 0
	t = 0
	for i in range(n):
		if lis[i] == '0':
			d = min(k, i - t)
			k -= d
			t += 1
			ans[i - d] = '0'
	print(*ans, sep='')


def query():
	(n, k) = map(int, input().split())
	bs = input()
	ans = ['1'] * n
	lz = 0
	for (i, b) in enumerate(bs):
		if b == '0':
			dif = min(k, i - lz)
			j = i - dif
			k -= dif
			lz = j + 1
			ans[j] = '0'
	print(''.join(ans))
q = int(input())
for _ in range(q):
	query()


q = int(input())
while q > 0:
	q -= 1
	(n, d) = list(map(int, input().split()))
	s = input()
	l = []
	for c in s:
		l.append(c)
	j = 0
	ans = ['' for i in range(n)]
	for i in range(n):
		if l[i] == '0':
			if i - j <= d:
				ans[j] = '0'
				l[i] = '*'
				d -= i - j
				j += 1
			else:
				ans[i - d] = '0'
				l[i] = '*'
				break
	i = 0
	index = 0
	while i < n:
		while l[index] == '*':
			index += 1
			if index >= n:
				break
		if index >= n:
			break
		if ans[i] == '':
			ans[i] = l[index]
			index += 1
		i += 1
	for k in ans:
		print(k, end='')
	print()
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	ans = ['1'] * n
	place = 0
	for i in range(n):
		if a[i] == '0':
			s = min(k, i - place)
			k -= s
			ans[i - s] = '0'
			place += 1
	print(''.join(ans))


t = int(input())
for _ in range(t):
	(n, k) = [int(p) for p in input().split()]
	s = list(input())
	curr = []
	j = 0
	for i in range(n):
		if k <= 0:
			break
		if s[i] == '1':
			curr.append(i)
		elif s[i] == '0' and j < len(curr):
			if k >= i - curr[j]:
				s[i] = '1'
				s[curr[j]] = '0'
				k -= i - curr[j]
				curr.append(i)
			else:
				s[i] = '1'
				s[i - k] = '0'
				break
			j += 1
	print(''.join(s))


import sys
from collections import deque
from queue import PriorityQueue
import math
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
for _ in range(ii()):
	(n, k) = il()
	a = list(ip())
	ind = 0
	b = []
	for i in range(n):
		if a[i] == '0':
			mn = max(ind, i - k)
			b.append(mn)
			xy = i - mn
			k = max(k - xy, 0)
			ind += 1
	if len(b) == 0:
		print(''.join(a))
	else:
		ans = ['1'] * n
		for i in b:
			ans[i] = '0'
		print(''.join(ans))


from sys import stdin
q = int(stdin.readline().strip())

def solve(s, k):
	zeroes = []
	ones_count = 0
	for (index, el) in enumerate(s):
		if el == '0':
			zeroes.append((index, ones_count))
		else:
			ones_count += 1
	zeroes_count = 0
	left = k
	for (index, ones) in zeroes:
		if ones > left:
			return '0' * zeroes_count + '1' * (ones - left) + '0' + '1' * left + s[index + 1:]
		zeroes_count += 1
		left -= ones
	return '0' * zeroes_count + '1' * (len(s) - zeroes_count)
for _ in range(q):
	(n, k) = [int(i) for i in stdin.readline().strip().split()]
	s = stdin.readline().strip()
	print(solve(s, k))


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	s = list(input())
	temp_list = []
	tmp_len = 0
	st = 0
	for i in range(n):
		if s[i] == '0':
			if k - (i - st) >= 0:
				(s[st], s[i]) = (s[i], s[st])
				k -= i - st
				st += 1
			else:
				shift = k
				(s[i - shift], s[i]) = (s[i], s[i - shift])
				break
		else:
			pass
	for i in s:
		print(i, end='')
	print()
	t -= 1


R = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, k) = R()
	L = input()
	p = k
	c = 0
	f = 1
	for i in range(n):
		if L[i] == '0':
			if k >= i - c:
				k -= i - c
			else:
				f = 0
				break
			c += 1
	if f:
		print('0' * c + '1' * (n - c))
	else:
		t = 0
		res = list(L)
		for i in range(n):
			if L[i] == '0':
				t += 1
			if t == c + 1:
				res[i - k] = '0'
				break
		for j in range(i + 1):
			if c > 0:
				res[j] = '0'
			else:
				res[j] = '1'
			c -= 1
		res[i - k] = '0'
		print(''.join(res))


IL = lambda : list(map(int, input().split()))
q = int(input())
for i in range(q):
	(n, k) = IL()
	s = input()
	f1 = (s.find('1') + n) % n
	s = list(s)
	seeds = [i for i in range(f1 + 1, n) if s[i] == '0']
	for seed in seeds:
		if k == 0:
			break
		if seed - f1 <= k:
			s[f1] = '0'
			s[seed] = '1'
			k -= seed - f1
			f1 += 1
		else:
			s[seed - k] = '0'
			s[seed] = '1'
			k = 0
	print(''.join(s))


import sys
import os
from io import IOBase, BytesIO
import math
mod = 10 ** 9 + 7
pie = 3.1415926536

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def ain():
	return list(map(int, sin().split()))

def sin():
	return input().strip()

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def read2DIntArray(row, col):
	arr = []
	for i in range(0, row):
		temp = list(map(int, sin().split()))
		arr.append(temp)
	return arr

def read2DCharArray(row, col):
	arr = []
	for i in range(0, row):
		temp = str(sin())
		arr.append(temp)
	return arr

def smallestNumber(n):
	lst = list(str(n))
	lst.sort()
	tmp = ''
	for (i, n) in enumerate(lst):
		if n != '0':
			tmp = lst.pop(i)
			break
	return str(tmp) + ''.join(lst)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	lst = []
	for p in range(n + 1):
		if prime[p]:
			lst.append(p)
	return lst

def nCr(n, r):
	a = 1
	b = 1
	c = 1
	for i in range(1, n + 1):
		c *= i
	for i in range(1, r + 1):
		b *= i
	for i in range(1, n - r + 1):
		a *= i
	return c // (a * b)

def sieveOfEratosthenes1(N, s):
	prime = [False] * (N + 1)
	for i in range(2, N + 1, 2):
		s[i] = 2
	for i in range(3, N + 1, 2):
		if prime[i] == False:
			s[i] = i
			for j in range(i, int(N / i) + 1, 2):
				if prime[i * j] == False:
					prime[i * j] = True
					s[i * j] = i

def generatePrimeFactors(N):
	s = [0] * (N + 1)
	sieveOfEratosthenes1(N, s)
	curr = s[N]
	cnt = 1
	factors = []
	power = []
	while N > 1:
		N //= s[N]
		if curr == s[N]:
			cnt += 1
			continue
		factors.append(curr)
		power.append(cnt)
		curr = s[N]
		cnt = 1
	return (factors, power)

def main():
	for _ in range(int(sin())):
		(n, k) = map(int, sin().split())
		s = sin()
		lst = []
		for i in range(n):
			if s[i] == '0':
				lst.append(i)
		j = 0
		for i in range(len(lst)):
			new_pos = j
			swaps = lst[i] - new_pos
			if swaps <= k:
				lst[i] = new_pos
				k -= swaps
			else:
				lst[i] = abs(lst[i] - k)
				break
			j += 1
		res = [1] * n
		for pos in lst:
			res[pos] = '0'
		print(*res, sep='')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import array
q = int(input())
res = []
for _ in range(q):
	(n, k) = map(int, input().strip().split(' '))
	s = array.array('B', [int(c) for c in input().strip()])
	s_new = array.array('B')
	cnt_one = 0
	for (i, x) in enumerate(s):
		if x == 1:
			cnt_one += 1
		else:
			shift = cnt_one
			if k > shift:
				s_new.append(0)
				k -= shift
			elif k == shift:
				s_new.append(0)
				s_new.extend([1] * cnt_one)
				s_new.extend(s[len(s_new):])
				cnt_one = 0
				break
			else:
				s_new.extend([1] * (cnt_one - k))
				s_new.append(0)
				s_new.extend([1] * k)
				s_new.extend(s[len(s_new):])
				cnt_one = 0
				break
	s_new.extend([1] * cnt_one)
	res.append(''.join(map(str, s_new)))
print('\n'.join(res))


import math
import sys
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = str(input())
	counter = 0
	moves_remain = k
	zeros = 0
	r = ''
	midlzero = 0
	left = 0
	right = 0
	for i in range(len(s)):
		if s[i] == '1':
			counter += 1
		elif counter <= moves_remain:
			zeros += 1
			moves_remain -= counter
		else:
			r = s[i + 1:len(s)]
			right = moves_remain
			midlzero = 1
			counter -= right
			break
	print('0' * zeros + '1' * counter + '0' * midlzero + '1' * right + r)


for z in range(int(input())):
	(n, k) = map(int, input().split())
	a = input()
	st = [0] * n
	li = []
	nl = []
	nst = [1] * n
	for i in range(n):
		if a[i] == '1':
			st[i] = 1
		else:
			li.append(i)
	pos = 0
	for i in li:
		if k >= i - pos:
			nl.append(pos)
			k -= i - pos
			pos += 1
		elif k == 0:
			nl.append(i)
		else:
			nl.append(i - k)
			k = 0
	for i in nl:
		nst[i] = 0
	for i in range(n):
		print(nst[i], end='')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	one_c = 0
	zero = []
	zero_c = []
	for i in range(len(s)):
		if s[i] == '1':
			one_c += 1
		else:
			zero.append(i)
			zero_c.append(one_c)
	for i in range(len(zero)):
		if k <= 0:
			break
		p = zero_c[i]
		if p == 0:
			continue
		elif k - p >= 0:
			zero[i] -= p
			k -= p
		else:
			zero[i] -= k
			k = 0
	ans = ['1'] * len(s)
	for x in zero:
		ans[x] = '0'
	print(''.join(ans))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // lcm(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	for _ in range(N()):
		(n, k) = RL()
		s = list(input())
		rec = [-1] * n
		one = 0
		for i in range(n):
			if s[i] == '1':
				one += 1
			else:
				rec[i] = one
		for i in range(n):
			if s[i] == '1':
				continue
			pre = min(k, rec[i])
			(s[i], s[i - pre]) = (s[i - pre], s[i])
			k -= pre
			if k < 0:
				break
		print(''.join(s))
main()


import sys
readline = sys.stdin.readline
rdw = lambda : readline().rstrip()
rdws = lambda : readline().split()
rdwl = lambda : list(readline().split())
rdi = lambda : int(readline())
rdis = lambda : map(int, readline().split())
rdil = lambda : list(map(int, readline().split()))
rdilrows = lambda cnt: [rdil() for _ in range(cnt)]

def solve():
	(n, k) = rdis()
	s = list(rdw())
	(i0, i1) = (0, 0)
	while True:
		while i1 < n and s[i1] != '1':
			i1 += 1
		while i0 < n and (i0 < i1 or s[i0] != '0'):
			i0 += 1
		if i0 < n and i1 < n:
			x = i0 - i1
			if x <= k:
				(s[i0], s[i1]) = ('1', '0')
				k -= x
			else:
				(s[i0], s[i0 - k]) = ('1', '0')
				break
		else:
			break
	print(''.join(s))
tests = 1
tests = rdi()
for testnum in range(tests):
	solve()


import sys
t = int(sys.stdin.readline())
for i in range(t):
	(n, k) = list(map(int, sys.stdin.readline().strip().split()))
	x = list(sys.stdin.readline())
	x = x[:-1]
	i = 0
	while i < n and x[i] == '0':
		i += 1
	c = i
	while i < n and k > 0:
		while i < n and x[i] == '1':
			i += 1
		if i == n:
			break
		if i - c <= k:
			x[i] = '1'
			x[c] = '0'
			k = k - (i - c)
			c += 1
		else:
			(x[i], x[i - k]) = (x[i - k], x[i])
			break
		i += 1
	print(''.join(x))


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	s = input()
	o = 0
	ans = ''
	for i in range(n):
		if k == 0:
			ans += s[i]
		elif s[i] == '1':
			o += 1
		elif k > o:
			ans += '0'
			k -= o
		elif o > k:
			ans += '1' * (o - k) + '0' + '1' * k
			k = 0
		else:
			ans += '0' + '1' * o
			k = 0
	if k != 0:
		ans += '1' * o
	print(ans)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	st = list(input())
	x = sorted(st)
	c = 0
	if x == st:
		print(*st, sep='')
		continue
	i = 0
	while i < n:
		if i <= c:
			i += 1
			continue
		if st[c] == '0':
			c += 1
			continue
		if st[i] == '0':
			sw = i - c
			if sw <= k:
				k -= sw
				(st[c], st[i]) = (st[i], st[c])
				c += 1
				i += 1
			else:
				(st[i - k], st[i]) = (st[i], st[i - k])
				break
				i += 1
		else:
			i += 1
	print(*st, sep='')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	o = ['1'] * n
	for (i, v) in enumerate((i for (i, c) in enumerate(input()) if c == '0')):
		d = min(v - i, k)
		k -= d
		o[v - d] = '0'
	print(''.join(o))


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, k) = [int(x) for x in stdin.readline().split()]
	s = list(stdin.readline().strip('\n'))
	ptr1 = 0
	while ptr1 < n and s[ptr1] != '1':
		ptr1 += 1
	ptr0 = ptr1 + 1
	while ptr0 < n and s[ptr0] != '0':
		ptr0 += 1
	while k > 0:
		if ptr0 == n or ptr1 == n:
			break
		if ptr0 - ptr1 <= k:
			(s[ptr1], s[ptr0]) = ('0', '1')
			k -= ptr0 - ptr1
		ptr1 = ptr1 + 1
		while ptr1 < n and s[ptr1] != '1':
			ptr1 += 1
		ptr0 = max(ptr0, ptr1 + 1)
		while ptr0 < n and s[ptr0] != '0':
			ptr0 += 1
	print(''.join(s))


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	a = list(map(int, input()))
	oneMet = 0
	for (i, d) in enumerate(a):
		if d:
			oneMet += 1
		elif k >= oneMet:
			(a[i - oneMet], a[i]) = (a[i], a[i - oneMet])
			k -= oneMet
		else:
			(a[i - k], a[i]) = (a[i], a[i - k])
			break
	print(''.join(map(str, a)))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	A = list(input())
	ans = ['1'] * n
	t = 0
	for j in range(n):
		if A[j] == '0':
			s = min(k, j - t)
			k -= s
			ans[j - s] = '0'
			t += 1
	print(''.join(ans))


import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	(N, K) = getInts()
	S = listStr()
	pref = [0]
	swaps = []
	curr = 0
	for s in S:
		if s == '1':
			curr += 1
		pref.append(curr)
	for j in range(N):
		if S[j] == '0' and pref[j] > 0:
			moves = min(K, pref[j])
			swaps.append((j, moves))
			K -= moves
		if K == 0:
			break
	for (ind, moves) in swaps:
		(S[ind], S[ind - moves]) = (S[ind - moves], S[ind])
	return ''.join(S)
for _ in range(getInt()):
	print(solve())


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = list(input())
	z = (i for (i, c) in enumerate(s) if c == '0')
	for (f, i) in enumerate(z):
		d = i - f
		if k < d:
			f = i - k
			k = 0
		else:
			k -= d
		(s[i], s[f]) = (s[f], s[i])
		if k == 0:
			break
	print(''.join(s))


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
MOD = pow(10, 9) + 7
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	s = input()
	ans = ['1'] * n
	for i in range(n):
		if s[i] == '0':
			ans[i] = '0'
	c = 0
	i = 0
	while k and i < n:
		if ans[i] == '0':
			v = max(c, i - k)
			ans[i] = '1'
			ans[v] = '0'
			c += 1
			k -= i - v
		i += 1
	print(''.join(ans))


Q = int(input())
for _ in range(Q):
	(N, K) = [int(x) for x in input().split()]
	binary_string = input()
	result = ''
	num_ones = 0
	over = False
	for (ind, ch) in enumerate(binary_string):
		if over:
			result += ch
			continue
		if ch is '0':
			expected_position = len(result)
			requirement = ind - expected_position
			if requirement is not 0:
				if K >= requirement:
					K -= requirement
					result += '0'
				else:
					for _ in range(num_ones - K):
						result += '1'
					result += '0'
					for _ in range(K):
						result += '1'
					over = True
					num_ones = 0
			else:
				result += '0'
		else:
			num_ones += 1
	for _ in range(num_ones):
		result += '1'
	print(result)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = str(input())
	arr = []
	ans = ['1'] * n
	p = 0
	for i in range(n):
		arr.append(s[i])
	for j in range(n):
		if arr[j] == '0':
			q = min(j - p, k)
			k -= q
			ans[j - q] = '0'
			p += 1
	print(''.join(ans))


import sys
q = int(sys.stdin.readline())
for x in range(q):
	[n, k] = [int(i) for i in sys.stdin.readline().split()]
	s = sys.stdin.readline().strip()
	if n == 1:
		print(s)
	else:
		arr = []
		for g in range(n):
			arr.append(s[g])
		ctr = 0
		last = 0
		ind = n - 1
		for h in range(n):
			if arr[h] == '1':
				ctr += 1
			elif ctr < k:
				k -= ctr
			elif ctr == k:
				k -= ctr
				ind = h
				break
			else:
				last = k
				k = 0
				ind = h
				break
		if last > 0:
			for p in range(ind, ind - last, -1):
				arr[p] = '1'
			arr[ind - last] = '0'
			for q in range(ind - last - 1, ind - ctr - 1, -1):
				arr[q] = '1'
			for r in range(ind - ctr - 1, -1, -1):
				arr[r] = '0'
		else:
			for p in range(ind, ind - ctr, -1):
				arr[p] = '1'
			for r in range(ind - ctr, -1, -1):
				arr[r] = '0'
		print(''.join(arr))


def f(s, k):
	t = s
	cnt = 0
	cnt0 = 0
	for i in range(len(s)):
		if s[i] == '1':
			cnt += 1
		if s[i] == '0':
			mn = min(cnt, k)
			k -= mn
			if k == 0:
				t = '0' * cnt0 + '1' * (cnt - mn) + '0' + '1' * mn + t[i + 1:]
				if k == 0:
					break
			else:
				cnt0 += 1
	if k and cnt0:
		mn = 0
		t = '0' * cnt0 + '1' * (cnt - mn) + '1' * mn
	return t
for _ in range(int(input())):
	(n, k) = map(int, input().strip().split())
	print(f(input(), k))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = input()
	null_pos = []
	begin = 0
	for i in range(n):
		if s[i] == '0':
			if k - (i - begin) >= 0:
				null_pos.append(begin)
				k = k - (i - begin)
			else:
				null_pos.append(i - k)
				k = 0
			begin += 1
	ans = ['' for i in range(n)]
	for i in null_pos:
		ans[i] = '0'
	for i in range(len(ans)):
		if ans[i] == '':
			ans[i] = '1'
	print(''.join(ans))


n = int(input())
while n > 0:
	(k, a) = map(int, input().split())
	p = input()
	p = list(p)
	count = a
	count_z = 0
	last_loc = None
	j = 0
	while count > 0 and j < k:
		try:
			loc = p.index('0', j, k)
		except ValueError:
			break
		diff = loc - count_z
		if diff > count:
			while count > 0:
				(p[loc], p[loc - 1]) = (p[loc - 1], p[loc])
				loc -= 1
				count -= 1
			break
		p[loc] = '1'
		p[count_z] = '0'
		last_loc = loc
		count_z += 1
		count -= diff
		j = last_loc + 1
	print(''.join(p))
	n -= 1


def count_zeros(string):
	cnt = 0
	for c in string:
		if c == '0':
			cnt += 1
	return cnt
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = input()
	m = count_zeros(s)
	if m == 0 or m == n:
		print(s)
		continue
	positions = [0] * m
	(first, j) = (-1, 0)
	for i in range(n):
		if s[i] == '1':
			if first < 0:
				first = i
		else:
			if first < 0:
				positions[j] = i
			else:
				shift = min(k, i - first)
				if shift < k:
					first += 1
				k -= shift
				positions[j] = i - shift
			j += 1
	res = ['0'] * n
	for k in range(positions[0]):
		res[k] = '1'
	for i in range(m - 1):
		for k in range(positions[i] + 1, positions[i + 1]):
			res[k] = '1'
	for k in range(positions[m - 1] + 1, n):
		res[k] = '1'
	print(''.join(res))


t = int(input())
while t:
	l = []
	(n, k) = map(int, input().split())
	s = input()
	for i in range(n):
		if s[i] == '0':
			l.append(i)
	for i in range(len(l)):
		if l[i] - i <= k:
			k -= l[i] - i
			l[i] = i
		else:
			l[i] -= k
			k = 0
	li = ['1'] * n
	for i in l:
		li[i] = '0'
	print(''.join(li))
	t -= 1


for step in range(int(input())):
	(n, k) = map(int, input().split())
	A = [i for i in input()]
	(cnt, t) = (0, 0)
	for i in range(n):
		if A[i] == '1':
			cnt += 1
		elif i - t <= k:
			(A[i], A[t]) = (A[t], A[i])
			t += 1
			k -= cnt
		else:
			(A[i], A[i - k]) = (A[i - k], A[i])
			k = 0
			break
	print(''.join(A))


q = int(input())
for _ in range(q):
	(n, k) = list(map(int, input().split(' ')))
	string = [0] * n
	string = list(input())
	string = list(map(int, string))
	count = 0
	for i in range(n):
		if k <= 0:
			break
		elif string[i] == 1:
			count += 1
			continue
		elif string[i] == 0:
			if count <= k:
				string[i] = 1
				string[i - count] = 0
				k -= count
			else:
				string[i] = 1
				string[i - k] = 0
				break
				count = 0
	for i in string:
		print(i, end='')
	print()


def swapPositions(list, pos1, pos2):
	first_ele = list.pop(pos1)
	second_ele = list.pop(pos2 - 1)
	list.insert(pos1, second_ele)
	list.insert(pos2, first_ele)
	return list
q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	jh = input()
	perm = []
	for l in jh:
		perm.append(int(l))
	ctr0 = 0
	ctr1 = 0
	cop = []
	for i in perm:
		cop.append(i)
	in0 = 0
	for j in range(len(perm)):
		if k == 0:
			break
		elif perm[j] == 0:
			if ctr1 == 0:
				in0 += 1
			elif k > j - in0:
				k -= j - in0
				cop[j] = 1
				cop[in0] = 0
				in0 += 1
			else:
				cop[j] = 1
				cop[j - k] = 0
				k = 0
				break
		else:
			ctr1 += 1
	for i in cop:
		print(str(i), end='')
	print()


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	(n, k) = f()
	ind = 0
	lzero = [1] * n
	s = si()
	maxind = n - 1
	ans = ''
	for i in range(n):
		if s[i] == '0':
			if i - ind <= k:
				lzero[ind] = 0
				k -= i - ind
				ind += 1
			else:
				maxind = i
				lzero[i - k] = 0
				break
	for i in range(maxind + 1):
		print(lzero[i], end='')
	for i in range(maxind + 1, n):
		print(s[i], end='')
	print()


import sys
import math
from collections import defaultdict, Counter, deque
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = list(input())
	start = 0
	c = 0
	for j in range(n):
		if s[j] == '0':
			need = j - start
			if k >= need:
				c += 1
				k -= need
				start += 1
			else:
				s[:j] = ['0'] * c + ['1'] * (j - c)
				for kk in range(j, start, -1):
					if k:
						(s[kk], s[kk - 1]) = (s[kk - 1], s[kk])
						k -= 1
					else:
						break
				print(''.join(s))
				break
	else:
		print('0' * c + '1' * (n - c))


from collections import deque
import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = input()
	ans = deque()
	cnt = 0
	flg = 1
	for i in range(n):
		if flg:
			if s[i] == '0':
				if i - cnt <= k:
					ans.appendleft(0)
					k -= i - cnt
					cnt += 1
				else:
					flg = 0
					j = i - k
			else:
				ans.append(1)
		else:
			ans.append(int(s[i]))
	if flg:
		print(''.join(map(str, ans)))
	else:
		ans = list(ans)
		ans1 = ans[:j]
		ans2 = ans[j:]
		print(''.join(map(str, ans1)) + '0' + ''.join(map(str, ans2)))


for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	s = input()
	p = s.find('0')
	if p == -1:
		print(s)
	elif s.find('1') == -1:
		print(s)
	else:
		oo = s.find('1')
		oop = oo
		j = 0
		l = [i for i in range(oo)]
		mx = len(s) - 1
		for i in range(oop, len(s)):
			if s[i] == '0':
				if k - j < i - oo:
					l.append(i - k + j)
					j += k - j
					mx = i
					break
				else:
					j += i - oo
					l.append(oo)
				oo += 1
		ss = ['1'] * (mx + 1 - oop)
		ss = ['0'] * oop + ss
		for i in l:
			ss[i] = '0'
		ss = ''.join(ss)
		ss = ss + s[mx + 1:]
		print(ss)


def run_testcase():
	[n, k] = [int(x) for x in input().split()]
	string = [int(x) for x in input()]
	current_index = 0
	search_index = 0
	while k > 0 and current_index < n:
		if string[current_index] == 0:
			current_index += 1
			continue
		next_zero_index = max(current_index, search_index)
		while next_zero_index < n and string[next_zero_index] != 0:
			next_zero_index += 1
		search_index = next_zero_index
		if next_zero_index >= n:
			break
		current_swap = max(current_index, next_zero_index - k)
		(string[current_swap], string[next_zero_index]) = (string[next_zero_index], string[current_swap])
		k -= next_zero_index - current_index
	print(*string, sep='')
testcase_count = int(input())
for i in range(testcase_count):
	run_testcase()


def process(n, k, bin_str):
	ops = k
	nx = 0
	while nx < n and bin_str[nx] == '0':
		nx += 1
	i = nx + 1
	while i < n and ops > 0:
		if bin_str[i] == '0':
			delta = min(i - nx, ops)
			bin_str[i - delta] = '0'
			bin_str[i] = '1'
			ops -= delta
			nx = i - delta + 1
		i += 1
	print(''.join(bin_str))
tc = int(input())
for i in range(tc):
	(n, k) = [int(x) for x in input().split()]
	bin_str = list(str(input()))
	process(n, k, bin_str)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	l = str(s)
	ans = []
	for i in range(n):
		if l[i] == '1':
			continue
		else:
			ans.append(i)
	j = 0
	for i in range(len(ans)):
		if ans[i] - j <= k:
			k -= ans[i] - j
			ans[i] = j
			j += 1
		else:
			ans[i] -= k
			k = 0
			break
	p = set(ans)
	for i in range(n):
		if i in p:
			print('0', end='')
		else:
			print('1', end='')
	print()


import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = list(input())
	o = 0
	ans = ''
	for i in range(n):
		if k > 0:
			if s[i] == '1':
				o += 1
			elif o > 0:
				if k >= o:
					k = k - o
					ans += '0'
				else:
					ans += (o - k) * '1' + '0'
					o = k
					k = 0
					ans += o * '1'
					o = 0
			else:
				ans += s[i]
			if k == 0:
				ans += o * '1'
				o = 0
		else:
			ans += s[i]
	ans += o * '1'
	sys.stdout.write(ans + '\n')


q = int(input())
for _ in range(q):
	(n, k) = [int(t) for t in input().split(' ')]
	s = input()
	ns = ['0'] * n
	nsp = 0
	lefty = 0
	while lefty < n and s[lefty] == '0':
		ns[nsp] = '0'
		nsp += 1
		lefty += 1
	l = lefty
	ones = 0
	while k > 0 and l < n:
		while l < n and s[l] == '1':
			ones += 1
			l += 1
		if l == n:
			break
		if l - lefty <= k:
			ns[nsp] = '0'
			nsp += 1
			k -= l - lefty
			lefty += 1
		else:
			for i in range(ones - k):
				ns[nsp] = '1'
				nsp += 1
			ns[nsp] = '0'
			nsp += 1
			for i in range(k):
				ns[nsp] = '1'
				nsp += 1
			k = 0
			ones = 0
		l += 1
	for i in range(ones):
		ns[nsp] = '1'
		nsp += 1
	for i in range(l, n):
		ns[nsp] = s[i]
		nsp += 1
	print(''.join(ns))


import random
from bisect import bisect_left, bisect_right
from typing import List
import collections
import bisect
import itertools
import functools
from fractions import gcd
import heapq
from math import ceil, sqrt, floor
from collections import defaultdict, deque
import collections
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = input()
	p = [1] * n
	left = 0
	for i in range(n):
		if s[i] == '0':
			if k <= 0:
				p[i] = 0
			else:
				swap_pos = max(i - k, left)
				p[swap_pos] = 0
				left += 1
				k -= i - swap_pos
	print(''.join((str(c) for c in p)))


from sys import stdin, stdout
from collections import defaultdict as df
import bisect
q = int(stdin.readline())
for ii in range(q):
	(n, k) = list(map(int, input().split()))
	s = input().rstrip()
	zeroes = []
	j = 0
	ans = [1] * n
	for i in range(n):
		if s[i] == '0':
			if i - j <= k:
				k -= i - j
				ans[j] = 0
				j += 1
			else:
				ans[i - k] = 0
				break
	for k in range(i + 1, n):
		ans[k] = int(s[k])
	ans = ''.join((str(e) for e in ans))
	print(ans)


query = int(input())
for _ in range(query):
	(a, b) = map(int, input().split())
	arr = list(input())
	last = 0
	for i in range(a):
		if arr[i] == '0':
			if b >= i - last:
				(arr[last], arr[i]) = (arr[i], arr[last])
				b -= i - last
				last += 1
			else:
				t = i - b
				(arr[t], arr[i]) = (arr[i], arr[t])
				break
	print(''.join(arr))


q = int(input())
for xd in range(q):
	(n, k) = [int(i) for i in input().split(' ')]
	idx = 0
	ones = 0
	off = 0
	line = input()
	for i in line:
		if i == '1':
			ones += 1
		else:
			if off + ones > k:
				break
			off += ones
		idx += 1
	right = line[idx:]
	diff = k - off
	left = ['0' for i in range(idx - ones)] + ['1' for i in range(ones)] + [j for j in right]
	if idx != n:
		left[idx] = '1'
		left[idx - diff] = '0'
	print(''.join(left))


def BinaryStringMinimizing(n, k, text):
	i = 0
	cnt = 0
	result = ''
	i0 = 0
	while i0 < n and k > 0:
		i0 = FindZeroAfterIndex(text, i0)
		if i0 == -1:
			break
		cnt = i0 - i
		if cnt <= k:
			text[i0] = '1'
			text[i] = '0'
			k -= cnt
		else:
			text[i0] = '1'
			text[i0 - k] = '0'
			k = 0
		i0 += 1
		i += 1
	result = ''.join(text)
	return result

def FindZeroAfterIndex(text, index):
	i = index
	while i < n:
		if int(text[i]) == 0:
			return i
		i += 1
	return -1
q = int(input())
result = ''
while q > 0:
	(n, k) = [int(x) for x in input().split()]
	text = [x for x in input()]
	result += BinaryStringMinimizing(n, k, text)
	if q > 1:
		result += '\n'
	q -= 1
print(result)


from sys import stdin, stdout, exit
for i in stdin:
	q = int(i.strip())
	break

def func():
	global s
	global k
	global j

	def swap(i):
		global s
		global k
		global j
		if k >= i - j:
			j2 = j
		else:
			j2 = i - k
		(s[j2], s[i]) = (s[i], s[j2])
		k -= min(k, i - j)
		j += 1
	for i in range(j + 1, len(s)):
		if not k:
			break
		elif s[i] == '0':
			swap(i)
for i in range(q):
	for i in stdin:
		(n, k) = list(map(int, i.strip().split()))
		break
	for i in stdin:
		s = list(i.strip())
		break
	try:
		j = s.index('1')
	except:
		k = 0
	if k:
		func()
	stdout.write(''.join(s) + '\n')


q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	s = input().strip()
	z = 0
	d = ['1' for j in range(n)]
	for i in range(n):
		if s[i] == '0':
			if k >= i - z:
				k -= i - z
				d[z] = '0'
				z += 1
			elif k > 0:
				d[i - k] = '0'
				k = 0
			else:
				d[i] = '0'
	print(''.join(d))


from math import *
from collections import *
t = int(input())
for y in range(t):
	(n, m) = map(int, input().split())
	a = input()
	c1 = []
	c0 = []
	for i in range(n):
		if a[i] == '1':
			c1.append(i)
		else:
			c0.append(i)
	st = 0
	lst = 0
	len0 = len(c0)
	while st < len0 and m != 0:
		x = c0[st] - st
		if x > m:
			lst = x - m
			m = 0
		else:
			st += 1
			m -= x
	l = ['a' for i in range(n)]
	for i in range(st):
		l[i] = '0'
	if st == len0:
		for i in range(st, n):
			l[i] = '1'
	else:
		for i in range(st, c0[st]):
			l[i] = '1'
		if lst != 0:
			l[lst + st] = '0'
			l[c0[st]] = '1'
		else:
			l[c0[st]] = '0'
		for i in c1:
			if i > c0[st]:
				l[i] = '1'
		for i in c0:
			if i > c0[st]:
				l[i] = '0'
	print(''.join(l))


import math
import sys
from collections import defaultdict
from itertools import groupby
input = sys.stdin.readline
rt = lambda : map(int, input().split())
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))

def main():
	q = ri()
	for _ in range(q):
		(n, k) = rt()
		s = list(input().strip())
		one = 0
		while one < n and s[one] == '0':
			one += 1
		zero = one
		while one < n and k > 0:
			while zero < n and s[zero] == '1':
				zero += 1
			if zero == n:
				break
			d = min(k, zero - one)
			k -= d
			(s[zero], s[zero - d]) = (s[zero - d], s[zero])
			one += 1
		print(''.join(s))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = input()
	lst = -1
	for i in range(n):
		if s[i] == '1':
			lst = i
			break
	if lst == -1:
		print(s)
		continue
	pos = [0] * n
	used = [False] * n
	for i in range(n):
		pos[i] = i
	for i in range(lst, n):
		if s[i] == '0':
			d = min(k, i - lst)
			pos[i] -= d
			k -= d
			lst += 1
			used[i] = True
	res = ['2'] * n
	for i in range(n):
		if s[i] == '0' and used[i]:
			res[pos[i]] = '0'
	c = 0
	for i in range(n):
		if res[i] == '2':
			c = i
			break
	for i in range(n):
		if not used[i]:
			res[c] = s[i]
			while res[c] != '2' and c < n - 1:
				c += 1
	print(''.join(res))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	bin_array = list(input())
	zeros_ind = (i for (i, x) in enumerate(bin_array) if x == '0')
	ans = ['1'] * n
	for (zeros_processed, zero) in enumerate(zeros_ind):
		s = min(k, zero - zeros_processed)
		k -= s
		ans[zero - s] = '0'
	print(''.join(ans))