#include <bits/stdc++.h>

using namespace std;

const int max_n = 2e5;
const int MOD = 1e9 + 7;
const long long INF = 1e18;

#define ll long long
#define fori(i, n) for (int i = 0; i < n; ++i)
#define all(v) v.begin(), v.end()
#define AIDAR ASSADULLIN

bool her_one(int n, int st) {
    return (n & st) == st;
}


signed main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin.tie(nullptr), cout.tie(nullptr), ios_base::sync_with_stdio(false), cout.precision(10);
    int qoq;
    cin >> qoq;
//   int qoq = 1;
    while (qoq--) {
        int n, m;
        string s;
        cin >> n >> m >> s;
        vector<int> a(n);
        set<int> id;
        fori(i, n) {
            a[i] = s[i] - '0';
            if (a[i] == 1)id.insert(i);
        }
        int last = -1;
        for (int ind: id) {
            if (last == -1) {
                last = ind;
                int ind_now = ind - 1;
                int cnt = m;
                while (cnt != 0 && ind_now != -1) {
                    a[ind_now] = 1;
                    cnt--;
                    ind_now--;
                }
            } else {
                int pl = 1;
                int cnt = m;
                while (cnt != 0 && ind - pl > last + pl) {
                    a[ind - pl] = 1;
                    a[last + pl] = 1;
                    pl++;
                    cnt--;
                }
                last = ind;
            }
        }
        int ind_now = last + 1;
        int cnt = m;
        while (cnt != 0 && ind_now < n && ind_now != 0) {
            a[ind_now] = 1;
            cnt--;
            ind_now++;
        }
        fori(i, n)cout << a[i];
        cout << "\n";
    }
}