#include <bits/stdc++.h>

#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define int long long int

#define pb push_back
#define mpp make_pair
#define F first
#define S second
#define vec vector<int>
#define pr vector<pair<int, int>>
#define vecv vector<vec>
#define vecs vector<string>
#define vecc vector<char>

#define pi 3.141592653589793238
#define mod 1000000007
#define Mod 998244353
#define inf 1e16
#define precise(i) cout << fixed << setprecision(i);
#define endl "\n"
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define one cout << -1 << endl;

#define err1(a) cout << #a << " " << a << endl;
#define err2(a, b) cout << #a << " " << a << " " << #b << " " << b << endl;
#define err3(a, b, c) cout << #a << " " << a << " " << #b << " " << b << " " << #c << " " << c << endl;

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(a) a.begin(), a.end()
#define show(a)             \
    for (auto xyz : a)      \
        cout << xyz << " "; \
    cout << endl;
#define show_nl(a)     \
    for (auto xyz : a) \
        cout << xyz << endl;
#define loop(a) for (auto xyz : a)
#define f(i, a, b) for (int i = a; i < b; i++)
#define rf(i, a, b) for (int i = b; i >= a; i--)

const long double eps = 1e-8;

#define lb lower_bound //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE
#define ub upper_bound //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE
using namespace std;

void help(int x, int y)
{
    cout << 2 << " " << x << " " << y << endl;
    cout << 1 << " " << x << " " << y << endl;
    cout << 2 << " " << x << " " << y << endl;
    cout << 1 << " " << x << " " << y << endl;
    cout << 2 << " " << x << " " << y << endl;
    cout << 1 << " " << x << " " << y << endl;
}

void solve()
{
    int n, m;
    cin >> n >> m;
    int k = min(n, m);
    string org, temp;
    cin >> org;
    while (k--)
    {
        temp = org;
        int i=0;
        while(i<n)
        {
            if (org[i] == '0')
            {
                if (i == 0)
                {
                    if (org[i + 1] == '1')temp[i] = '1';
                }
                else if (i == n - 1)
                {
                    if (org[i - 1] == '1')temp[i] = '1';
                }
                else
                {
                    if ((org[i - 1] == '1' && org[i + 1] != '1') || (org[i - 1] != '1' && org[i + 1] == '1'))temp[i] = '1';
                }
            }
            i++;
        }
        org = temp;
        // cout<<s<<endl;
    }
    cout << temp<<endl;
}

signed main()
{
    fastio;
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}