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

typedef long long LL;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 1e3 + 10;

int a[N];

void solve() {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) {
		scanf("%1d", &a[i]);
	}
	a[n + 1] = a[0] = 0;
	m = min(1000, m);
	while(m--) {
		vector<int> v;
		for(int i = 1; i <= n; i++) {
			if(a[i] == 0 && a[i - 1] + a[i + 1] == 1) {
				v.push_back(i);
			}
		}
		for(auto x : v) {
			a[x] = 1;
		}
	}
	for(int i = 1; i <= n; i++) {
		printf("%d", a[i]);
	}
	puts("");
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int t; cin >> t; while(t--)
    solve();
    return 0;
}
