#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define mx LLONG_MAX
#define mn LLONG_MIN
#define pii pair<int,int>
#define vi vector<int>
#define vll vector< long long >
#define pb push_back
#define pop pop_back
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define f(i,a,n) for( i = a ; i < n ; i++)
using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
        freopen ("input.txt","r",stdin); 
        freopen ("output.txt","w",stdout);
    #endif
    fastIO;
    int TESTS = 1; 
    cin>>TESTS;
    while(TESTS--)
    {
        int i,n,m; cin>>n>>m;
        vector<char> s(n);
        f(i,0,n) cin>>s[i];

        while(true)
        {
            vector<char> t(n);

            for(int i = 0 ; i<n ; i++)
            {
                if(s[i] == '0')
                {
                    if(i == 0)
                    {
                        if(s[1] == '1') 
                            t[0] = '1';
                        else 
                            t[0] = '0';
                    }
                    else if( i == n-1 )
                    {
                        if(s[n-2] == '1')
                            t[n-1] = '1';
                        else 
                            t[n-1] = '0';
                    }
                    else
                    {
                        if(s[i-1] == '1' && s[i+1] == '1') t[i] = '0';
                        else if(s[i-1] == '1' || s[i+1] == '1') t[i] = '1';
                        else t[i] = '0';
                    }
                }
                else t[i] = '1';
            }
            m--;

                if(s == t || m == 0)
                {
                    s = t;
                    break;
                }
                s = t;
        }
        for(auto it : s) cout<<it; cout<<endl;
    } 
}