#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i,n) for(i=0; i<n; i++)
#define repa(i,a,n) for(i=a; i<n;i++)
#define repit(x, k) for(auto x:k)
#define vi vector<int>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define pb(t) push_back(t)
#define ins(t) insert(t)
#define mp(a,b) make_pair(a, b)
#define mset(a, val) memset(a, val, sizeof(a))
#define all(v) v.begin(), v.end()

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define M 1000000007 // 9 zeros + 5
#define epsilon 1e-9
#define PI  3.14159265
#define INF 1e9+5
#define INFF  1000000000000000005ll //18 zeros + 5

int main(){
  SPEED;
  ll i,j,k;
  
  int t;
  cin>>t;
  while(t--){

    int n;
    ll m;
    cin>>n>>m;

    string s="";
    string s1;
    cin>>s1;
    s+='$';
    s+=s1;
    s+='$';
    // cout<<s<<endl;
    vi zeros;
    vi ones;
    rep(i,n+2){
      if(s[i]=='0') zeros.pb(i);
      else ones.pb(i);
    }
    // string s1= s;
    while(m--){
      s1 = s;
      rep(i, s1.length()){
        if(s1[i]=='$') continue;
        if(s1[i] == '0'){

          if(s[i+1]=='1' && s[i-1]!='1'){
            s1[i]='1';
          }
          if(s[i-1]=='1' && s[i+1]!='1'){
            s1[i]='1';
          }

        }
      }
      // cout<<s1<<endl;
      if(s1 == s) break;
      s = s1;

    }
    

    // cout<<"-"<<endl;
    rep(i, s.length()){
      if(s[i]=='$') continue;
      cout<<s[i];
    }
    cout<<endl;
    // cout<<"____________"<<endl;

  }  



  return 0;
}
