#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, m, n, ct;
  string s;
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    ct = 0;
    vector<int> v;
    long long int a[n];
    bool init = false;
    long long int spaces = 0;
    cin.ignore();
    for (i = 0; i < n; i++) {
      char c;
      cin >> c;
      a[i] = c - '0';
      if (a[i] == 1) {
        init = true;
        v.push_back(ct), ct = 0;
      } else {
        ct++;
      }
      if (!init) spaces++;
    }
    if (ct != 0) v.push_back(ct);
    for (i = 1; i < v.size(); i++) {
      if (k < i * v[i]) break;
      k -= i * v[i];
      spaces += v[i];
    }
    if (i == v.size()) {
      sort(a, a + n);
      for (i = 0; i < n; i++) cout << a[i];
      cout << "\n";
    } else {
      spaces += k / i;
      for (j = 0; j < spaces; j++) cout << "0";
      j = 0;
      while (j < i - k % i) cout << "1", j++;
      cout << "0";
      while (j < i) cout << "1", j++;
      for (i = spaces + i + 1; i < n; i++) cout << a[i];
    }
    cout << "\n";
  }
  return 0;
}
