#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int T;
    cin>>T;
    while(T--)
    {
        int n,m;
        cin>>n>>m;
        
        string s;
        cin>>s;
        
        int temp=min(n,m);
        while(temp--)
        {
            
            string ans=s;
            
            if(s[0]=='0' && s[1]=='1')
            ans[0]='1';
            
            if(s[n-1]=='0' && s[n-2]=='1')
            ans[n-1]='1';
            
            for(int i=1;i<n-1;i++)
            {
                if(s[i]=='0')
                if((s[i-1]=='1' && s[i+1]=='0') || (s[i-1]=='0' && s[i+1]=='1'))
                ans[i] = '1';
            }
            
            s=ans;
        }
        cout<<s<<endl;
    }
    
    return 0;
}