#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        string s;
        cin>>s;
        for(int i=1;i<=min(m,n);i++){
            string r=s;
            for(int j=0;j<n;j++){
                if(r[j]=='0' && j==0){
                    if(r[j+1]=='1'){
                        s[0]='1';
                    }
                }
                else if(r[j]=='0' && j==n-1){
                    if(r[j-1]=='1'){
                        s[n-1]='1';
                    }
                }
                else if(r[j]=='0'){
                    if((r[j+1]=='1' && r[j-1]=='0') || (r[j+1]=='0' && r[j-1]=='1')){
                        s[j]='1';
                    }
                }
            }
            
        }
        cout<<s<<"\n";
    }
}