#include <bits/stdc++.h>
#define int long long 
using namespace std;
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
       int n,m;
       cin>>n>>m;
       string s;
       cin>>s;
       string ss=s;
      while(m--)
      {
          int cnt=0;
          for(int i=0;i<n;i++)
          {
              if(s[i]=='0')
              {
                  if(i==0 and s[i+1]=='1')
                  {
                      ss[i]='1';
                      cnt++;
                  }
                  else if(i==n-1 and s[i-1]=='1')
                  {
                      ss[i]='1';
                      cnt++;
                  }
                  else if(i!=0 and i!=n-1)
                  {
                      if((s[i-1]=='1' and s[i+1]=='0') or (s[i-1]=='0' and s[i+1]=='1'))
                      {
                          ss[i]='1';
                          cnt++;
                      }
                  }
              }
          }
          s=ss;
          if(cnt==0)
          break;
      }
      cout<<s<<endl;
    }
}