#include<bits/stdc++.h>

#define sz(a) (int)a.size()
#define pb push_back
#define all(a) a.begin(), a.end()
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define x first
#define y second
#define int long long

using namespace std;
typedef pair<int, int> pii;


signed main(){
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
       ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

   int u;
   cin >> u;
   while(u--){
        int n, k;
        cin >> n >> k;
        string s;
        cin >> s;

        for0(i, min(1000LL, k)){
            vector<int> v;
            for0(i, sz(s))
                if(s[i] == '0'){
                        int tt = 0;
                    if(i > 0)
                        tt += s[i-1] == '1';
                    if(i < n - 1)
                        tt += s[i+1] == '1';

                    if(tt == 1)
                        v.pb(i);
                }
            for(auto q : v)
                s[q] = '1';
        }

        cout << s<<endl;

   }




}
