#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<long long> P;
    for (long long i = 1; i <= n; i++) {
      if (s[i - 1] == '0') P.push_back(i);
    }
    long long sii = P.size();
    vector<long long> Q;
    long long which = 1;
    for (auto it = P.begin(); it != P.end(); it++) {
      long long m = *it;
      if (k == 0) {
        Q.push_back(m);
      } else {
        long long diff = m - which;
        if (diff <= k) {
          Q.push_back(which);
          k -= diff;
        } else {
          Q.push_back(m - k);
          k = 0;
        }
      }
      which++;
    }
    char fin[n];
    for (long long xx = 0; xx < n; xx++) fin[xx] = '1';
    for (auto it = Q.begin(); it != Q.end(); it++) {
      long long m = *it;
      fin[m - 1] = '0';
    }
    for (long long xx = 0; xx < n; xx++) cout << fin[xx];
    cout << endl;
  }
}
