//
#include <bits/stdc++.h>

using namespace std;
#define task        ""
#define maxn        1005
#define maxm
#define maxs
#define bug(a)      cerr << int (a) << "\n"
#define ms(a,b)     memset (a, b, sizeof (a))
#define p_b         push_back
#define x           first
#define y           second
#define oo          2000000000
#define mod         1000000007
#define ll          long long

typedef pair <int, int> II;
typedef pair <II, int> III;

int n, m;
string s;
int f[maxn], g[maxn];

void solve() {
    cin >> n >> m >> s;
    s = " " + s;
    f[0] = oo; 
    g[n + 1] = oo;
    for (int i = 1; i <= n; i++) {
        if (s[i] == '1') f[i] = 0;
        else {
            f[i] = f[i - 1] + 1;
        }
    }
    for (int i = n; i >= 1; i--) {
        if (s[i] == '1') g[i] = 0;
        else {
            g[i] = g[i + 1] + 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        if ((min (f[i], g[i]) <= m && f[i] != g[i] && s[i] == '0') || s[i] == '1') cout << 1;
        else cout << 0;
    }
    cout << "\n";
}

//
int main() {
#ifndef ONLINE_JUDGE
    freopen(".inp","r",stdin);
    freopen(".out","w",stdout);
#endif // ONLINE_JUDGE
//    freopen (task".inp", "r", stdin);
//    freopen (task".out", "w", stdout);
    ios::sync_with_stdio (false);
//    cin.tie(0);
//    cout.tie(0);
    int T;
    cin >> T;
    while (T--) {
        solve();
    }
}
