#include <iostream>
#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;
        string s2=s;
        while(m--)
        {
            int count=0;
            for(int i=0;i<n;i++)
            {
                if(i==0 && s[i]=='0')
                {
                    if(s[i+1]=='1')
                    {
                        s2[i]='1';
                        count++;
                    }
                }
                else if(i==n-1 && s[i]=='0')
                {
                    if(s[i-1]=='1')
                    {
                        s2[i]='1';
                        count++;
                    }
                }
                else
                {
                    if(s[i]=='0' && s[i-1]=='1' && s[i+1]=='0')
                    {
                        s2[i]='1';
                        count++;
                    }
                    else if(s[i]=='0' && s[i-1]=='0' && s[i+1]=='1')
                    {
                        s2[i]='1';
                        count++;
                    }
                }
            }
            
            s=s2;
            if(count==0)
            {
                break;
            }
            
            
        }
        cout<<s<<endl;
    }
}
