// Problem: A. Game of Life
// Contest: Codeforces - Deltix Round, Spring 2021 (open for everyone, rated, Div. 1 + Div. 2)
// URL: https://codeforces.com/contest/1523/problem/0
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define uset unordered_set
#define umap unordered_map
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a));
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const int MM = 1e3+5;
char grid[MM][MM];
void solve() {
	int N, M;
	cin >> N >> M;
	for (int i = 1; i <= N; ++i) cin >> grid[0][i];
	for (int i = 1; i <= 1000; ++i) {
		for (int j = 1; j <= N; ++j) {
			if (j == 1) {
				if (grid[i - 1][j + 1] == '1') {
					grid[i][j] = '1';
				} else grid[i][j] = grid[i - 1][j];
				continue;
			} else if (j == N) {
				if (grid[i - 1][j - 1] == '1') {
					grid[i][j] = '1';
				} else grid[i][j] = grid[i - 1][j];
				continue;
			}
			if (grid[i - 1][j - 1] == '1' && grid[i - 1][j + 1] == '1') grid[i][j] = grid[i - 1][j];
			else if (grid[i - 1][j - 1] == '1' || grid[i - 1][j + 1] == '1') {
				grid[i][j] = '1';
			} else grid[i][j] = grid[i - 1][j];
		}
	}
	//cout << min(M, 1000);
	for (int i = 1; i <= N; ++i) {
		cout << grid[min(M, 1000)][i];
	}
	cout << "\n";
}
int main() {
	//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int T;
	cin >> T;
	while (T--) solve();
}