#include <bits/stdc++.h>
#define itn int
#define INF 0x3f3f3f3f
#define MIN 0xc0c0c0c0
#define FR(i,n,m)  for(int i=n;i<=m;i++)
#define FR1(i,m,n) for(int i=m;i>=n;i--)
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int main() {
    int t;
    string a, b;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m >> a;
        b = a;
        int flag = 0;
        FR(i, 0, n - 1) if (a[i] == '1') flag = 1;
        if (!flag) {
            FR(i, 1, n) printf("0");
            printf("\n");
            continue;
        }
        if (m > 1000) m = 1000;
        FR(j, 1, m) {
            b = a;
            FR(i, 0, n - 1) {
                if ((a[i - 1] == '1' && a[i + 1] != '1') || (a[i + 1] == '1' && a[i - 1] != '1')) b[i] = '1';
            }
            a = b;
        }
        cout << a << endl;
    }
    return 0;
}