#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  ;
  cin.tie(0);
  ;
  long long int i, j, t, x, y, n, k, f, ctr = 0, one, zero;
  string s;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    cin >> s;
    s = " " + s;
    f = 0;
    ctr = 0;
    for (i = 1; i <= n; i++) {
      if (s[i] == '1')
        ctr++;
      else {
        if (k >= ctr)
          k -= ctr;
        else {
          one = ctr;
          zero = i - 1 - one;
          for (j = 1; j <= zero; j++) cout << "0";
          for (j = 1; j <= ctr - k; j++) cout << "1";
          cout << "0";
          for (j = 1; j <= k; j++) cout << "1";
          for (j = i + 1; j <= n; j++) cout << s[j];
          cout << "\n";
          f = 1;
          break;
        }
      }
    }
    if (f) continue;
    for (i = 1; i <= n - ctr; i++) cout << "0";
    for (i = 1; i <= ctr; i++) cout << "1";
    cout << "\n";
  }
  return 0;
}
