#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int count0 = 0;
    int j = 0;
    bool flag = false;
    while (j < n && k > 0) {
      if (s[j] == '1') {
        j++;
        continue;
      }
      if (j <= k + count0) {
        k = k - j + count0;
        count0++;
        j++;
      } else {
        flag = true;
        break;
      }
    }
    if (!flag) {
      for (int l = 0; l < count0; l++) cout << 0;
      for (int l = 0; l < n; l++) {
        if (s[l] == '1') {
          if (!flag) {
            cout << 1;
            continue;
          }
          if (k > 0) {
            k--;
            cout << 1;
            continue;
          }
        }
        if (count0 > 0) {
          count0--;
          continue;
        }
        cout << 0;
      }
    } else {
      for (int l = 0; l < count0; l++) cout << 0;
      int w = 0;
      for (int l = 0; l < n; l++) {
        if (s[l] == '1') {
          if (!flag) {
            cout << 1;
            continue;
          }
          w++;
          continue;
        }
        if (count0 > 0) {
          count0--;
          continue;
        }
        if (flag) {
          string s2(w - k, '1');
          string s3(k, '1');
          cout << s2 << 0 << s3;
          flag = false;
          continue;
        }
        cout << 0;
      }
    }
    cout << endl;
  }
  return 0;
}
