#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for( int i=(a); i<(b); ++i)
#define REP(i,a,b) for( int i=(a); i<=(b); ++i)
#define MOD 1000000007
#define mp(x,y) make_pair(x,y);
#define mem(a,val) memset(a,val,sizeof(a))
#define pb push_back
#define sz(x) (int(x.size()))
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

inline void YES() { cout << "YES" << endl;}
inline void NO()  { cout <<  "NO" << endl;}
const int maxn = 100005;

void solve(){
    int n, m; cin >> n >> m;
    string s; cin >> s;
    vector<int> idx;
    for(int i = 0; i < n; i++)
        if(s[i] == '1') idx.push_back(i);
    if(idx.empty()) {
        cout << s << endl;
        return;
    }else{
        set<int> ban;
        for(int i = 1; i < idx.size(); i++){
            if(!((idx[i] - idx[i-1]) & 1)) ban.insert((idx[i] + idx[i-1])/2);
        }
        int i = 0;
        while(i  < sz(idx)){
            int cur = max(0, idx[i] - m);
            int nxt = min(n, idx[i] + m);
            for(int i = cur; i <= nxt; i++){
                if(ban.count(i)) continue;
                s[i] = '1';
            }
            if(nxt == n){
                cout << s << endl;
                return;
            }
            i++;
        }
        cout << s << endl;
    }
}


int main() {
#ifndef ONLINE_JUDGE
    freopen("../Standard/in.dat","r",stdin);
    freopen("../Standard/out.dat","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
    cin >> T;
    while(T--){
        solve();
    }
    return 0;
}