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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        long long int n, m;
        cin >> n >> m;
        string arr, res;
        cin >> arr;
        res = arr;
        for (long long int i = 0; i < m; i++)
        {
            if (arr[0] == '0' && arr[1] == '1')
            {
                res[0] = '1';
            }
            if (arr[n - 1] == '0' && arr[n - 2] == '1')
            {
                res[n - 1] = '1';
            }

            for (int j = 1; j < n - 1; j++)
            {
                if (arr[j] == '0')
                {
                    int a = (int)(arr[j - 1]);
                    int b = (int)(arr[j + 1]);
                    if (a ^ b)
                    {
                        res[j] = '1';
                    }
                }
            }
            if (arr == res)
            {
                break;
            }
            arr = res;
            //cout<<arr<<endl;
        }
        cout << res << endl;
    }
    return 0;
}
