#include<fstream>
#include<iostream>
#include<sstream>
#include<iomanip>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<functional>
#include<numeric>
#include<bitset>
#include<cassert>
#include<array>
#include "string.h"
#include "math.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp make_pair

#ifndef BLAH
#define fin cin
#define fout cout
#endif

namespace
{

}

int main()
{
	ios::sync_with_stdio(0);
#ifdef BLAH
	ifstream fin("test.in");
	ofstream fout("test.out");
#endif

	int zzz; fin >> zzz;
	for (int zz = 1; zz <= zzz; ++zz)
	{
		int n, m; fin >> n >> m;
		string s, ss;
		fin >> s;
		s = '0' + s + '0';

		for (int t = 0; t < m; ++t)
		{
			ss = s;
			for (int i = 1; i <= n; ++i)
			{
				if (s[i - 1] != s[i + 1])
					ss[i] = '1';
			}
			if (s == ss) break;
			swap(s, ss);
		}

		fout << s.substr(1, n) << endl;
	}

	return 0;
}

