#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
 
using namespace std;

namespace model{
	const int N = 1e6+7,P=998244353;
	int read()
	{
		int a = 0,x = 1;char ch = getchar();
		while(ch > '9' || ch < '0') {if(ch == '-') x = -1;ch = getchar();}
		while(ch >= '0' && ch <= '9'){a = a*10 + ch-'0';ch = getchar();}
		return a*x;
	}
	int fpow(int a,int x,int p) 
	{
		if(x == 1) return a;
		if(x == 0) return 1;
		int t = fpow(a,x>>1,p);
		if(x&1) return t*t%p*a%p;
		return t*t%p;
	}
	void Mod(int &a) {if(a >= P) a %= P;}
}

using model::read;
using model::N;
const int inf=2e9+7;
char s[N];
int a[N],l[N],r[N];
void solve()
{
	int n = read(),m = read();
	scanf("%s",s+1);
	for(int i = 1;i <= n;i ++) a[i] = s[i]-'0';
	for(int i = 1,tmp = -inf;i <= n;i ++) {
		if(!a[i]) l[i] = i-tmp;
		else tmp = i;
	}
	for(int i = n,tmp = inf;i >= 1;i --) {
		if(!a[i]) r[i] = tmp-i;
		else tmp = i;
	}
	for(int i = 1;i <= n;i ++) {
		if(a[i]) printf("%d",a[i]);
		else {
			if(min(l[i],r[i]) <= m && l[i] != r[i]) printf("1");
			else printf("0");
		}
	}
	puts("");
	return ;
}

int main()
{
	int t = read();
	while(t --) solve();
}
