#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	ll t;
	cin>>t;
	while(t--){
		ll n,m;
		cin>>n>>m;
		string s;
		cin>>s;
		vector<ll>v;
		for(ll i=0;i<n;i++){
			if(s[i]=='1') v.push_back(i);
		}	
		if(v.size()==0){
			cout<<s<<endl;
		}else{
	    	ll j=v[0]-1;
	    	ll a=m;
	    		while(a-- && j>=0){
	    			s[j]='1';
	    			j--;
	    		}
			 j=v[v.size()-1]+1;
			 ll b=m;
				while(b-- && j<n){
					s[j]='1';
					j++;
				}
				
		for(ll i=0;i<v.size();i++){
			ll d=m;
			if(i==v.size()-1) break;
			 j=v[i]+1;
			ll k=v[i+1]-1;
			while(d-- && j<k){
				s[j]='1';
				j++;
				s[k]='1';
				k--;
			}
		}
		cout<<s<<endl;
	  }
	}
}