#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, d;
  cin >> t;
  while (t--) {
    string s;
    cin >> n >> d;
    cin >> s;
    long long x = 0, y = 0, z = 0;
    for (long long i = 0; i < s.size(); ++i) {
      if (s[i] == '1')
        ++x;
      else {
        if (d >= x && x != 0) {
          ++y;
          s[i] = 'a';
          d = d - x;
        } else if (d < x) {
          z = 1;
          s[i] = 'a';
          break;
        }
      }
    }
    if (z == 1) {
      int e = 0;
      for (long long i = 1; i <= y; ++i) cout << "0";
      for (long long i = 0; i < s.size(); ++i) {
        if (s[i] != 'a') {
          if (s[i] == '1') {
            ++e;
            if (e == x - d)
              cout << "10";
            else
              cout << "1";
          } else
            cout << "0";
        }
      }
    } else {
      for (long long i = 1; i <= y; ++i) {
        cout << "0";
      }
      for (long long i = 0; i < s.size(); ++i) {
        if (s[i] != 'a') cout << s[i];
      }
    }
    cout << endl;
  }
  return 0;
}
