#include<bits/stdc++.h>
using namespace std;

#define  CIN            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define  ll             long long int
#define  pb             push_back

vector<ll>v1;
string s1;

int main()
{
    CIN;
    ll  a,b,i,T=1;
    cin>> T ;
    while(T--)
    {
        v1.clear();
        cin >> a >> b >> s1 ;
        ll x = min(a,b) ;
        while( x--)
        {
            v1.clear();
            for( i = 0 ; i <  a ; i++)
            {
                if(s1[i]=='0')
                {
                    if(i==0)
                    {
                        if(s1[i+1]=='1')
                            v1.pb(i);
                    }
                    else if(i==a-1)
                    {
                        if(s1[i-1]=='1')
                            v1.pb(i);
                    }
                    else if((s1[i+1]=='1' && s1[i-1]=='0') || (s1[i+1]=='0' && s1[i-1]=='1'))
                        v1.pb(i);
                }
            }
            for( i = 0 ; i < v1.size() ; i++) s1[v1[i]]='1';
        }
        cout<<s1<<endl;
    }
    return 0 ;
}
