#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long T;
  cin >> T;
  while (T--) {
    long long n, k;
    cin >> n >> k;
    string s;
    vector<long long> zero(n, 0);
    cin >> s;
    long long o = 0;
    for (long long i = 0; i < s.size(); i++) {
      if (s[i] == '1')
        o++;
      else {
        long long go = min(k, o);
        k -= go;
        zero[i - go] = 1;
      }
    }
    for (auto u : zero) {
      if (u)
        cout << 0;
      else
        cout << 1;
    }
    cout << "\n";
  }
}
