//team lots of balloons
//author: CN.TTDragon
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=1e3+7;
const double pi=acos(-1);
using namespace std;
int _,n,m;
int a[maxn];
char s[maxn];
int l[maxn];
int r[maxn];
int ans[maxn];
char nex[maxn];
int main()
{
    ios::sync_with_stdio(false);
    //freopen("in.in","r",stdin);
    //freopen("mine.out","w",stdout);
	for(cin>>_;_;_--)
	{
		memset(ans,0,sizeof(ans));
		memset(l,0,sizeof(l));
		memset(r,0,sizeof(r));
		cin>>n>>m;
		cin>>(s+1);
		s[0]='0';
		s[n+1]='0';
		int ti=min(n,m);
		while(ti--)
		{
			for(int i=1;i<=n;i++)
			{
				if(s[i]=='0')
				{
					
					if((s[i-1]=='0'&&s[i+1]=='1')||(s[i-1]=='1'&&s[i+1]=='0'))
					{
						nex[i]='1';
					}
					else
					{
						nex[i]='0';
					}
				}
				else
				{
					nex[i]='1';
				}
			}
			for(int i=1;i<=n;i++)
			{
				s[i]=nex[i];
			}
		}
		
		for(int i=1;i<=n;i++)
		{
			cout<<s[i];
		}
		cout<<endl;
	}
 	return 0;
}
