#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int it = 0; it < t; it++) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ones = 0, ind = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == '1')
        ones++;
      else {
        if (k >= ones) {
          k -= ones;
          cout << "0";
          ind++;
        } else {
          for (int j = 0; j < ones - k; j++) {
            cout << "1";
            ind++;
          }
          ones = k;
          k = 0;
          cout << "0";
          for (int j = 0; j < ones; j++) {
            cout << "1";
            ind++;
          }
          ones = 0;
          ind++;
          break;
        }
        if (k == 0) {
          break;
        }
      }
    }
    for (int i = 0; i < ones; i++) {
      cout << "1";
      ind++;
    }
    for (int i = ind; i < s.length(); i++) cout << s[i];
    cout << "\n";
  }
  return 0;
}
