#include<iostream>
#include<vector>
#include<cstdlib>
#include<algorithm>
#include<climits>
#include<queue>
#include<stack>
#include<cmath>
#include<iterator>
#include<set>
typedef long long ll;
using namespace std;
#define rep(x, y)   for (ll i = x; i < y; i ++)
#define repi(x, y)  for (ll i = x; i > y; i --)
#define si(x) ll x;cin>>x
ll arr[200005];
stack<ll> leftz;
stack<ll> rightz;
priority_queue<ll>uleft;
priority_queue<ll, vector<ll>, greater<ll> >uright;
// ll poses[5005][2];
int main()
{
    ll test;
    cin>>test;
    for(ll z=0;z<test;z++)
    {
        si(n);
        si(m);
        string ss;
        cin>>ss;
        ll countprev = 0;
        for(ll i=0;i<n;i++)
        {
            if(ss[i] == '1')
            {
                countprev ++;
            }
        }
        ll counter = 0;
        string s = "";
        for(ll i=0;i<n;i++)
        {
            s+=ss[i];
        }
        ll prevm = m;
        while(m>0 && countprev != counter)
        {
            // cout<<m<<countprev<<counter<<endl;
            for(ll i=0;i<n;i++)
            {
                ss[i] = s[i];
            }
            if(m != prevm)
            {
                countprev = counter;
            }
            counter = 0;
            for(ll i=0;i<n;i++)
            {
                if(i == 0)
                {
                    if(ss[i] == '0')
                    {
                        if(ss[i+1] == '1')
                        {
                            s[i] = '1';
                            counter++;
                        }
                    }
                    else
                    {
                        counter++;
                    }
                }
                else if(i == n-1)
                {
                    if(ss[i] == '0')
                    {
                        if(ss[i-1] == '1')
                        {
                            s[i] = '1';
                            counter++;
                        }
                    }
                    else
                    {
                        counter++;
                    }
                }
                else
                {
                    if(ss[i] == '0' &&( ( (ss[i-1] == '1') && (ss[i+1] == '0')) || ( (ss[i-1] == '0') && (ss[i+1] == '1')) ))
                    {
                        s[i] = '1';
                        counter ++;
                    }
                    else
                    {
                        if(s[i] == '1')
                        {
                            counter++;
                        }
                    }
                }
                
            }
            m--;
        }
        cout<<s<<endl;
    }
    
}