#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long q, w, e;
  string r;
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> w >> e;
    cin >> r;
    long long j = 0, k = 0;
    while (j < w && e > 0) {
      if (r[j] == '0') {
        if (e >= j - k) {
          swap(r[j], r[k]);
          e -= j - k;
          k++;
        } else {
          swap(r[j], r[j - e]);
          e = 0;
        }
      }
      j++;
    }
    cout << r << '\n';
  }
}
