#include <bits/stdc++.h>
using namespace std;
int main() {
  long long q;
  cin >> q;
  while (q--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    long long lz = -1, ocnt = 0;
    for (long long i = 0; i < s.size(); i++) {
      if (k == 0) break;
      if (s[i] == '1') ocnt++;
      if (s[i] == '0') {
        if (ocnt == 0) {
          lz = i;
          continue;
        }
        long long dist = i - (lz + 1);
        if (dist <= k) {
          k = k - dist;
          s[lz + 1] = '0';
          s[i] = '1';
          lz++;
        } else {
          long long x = i - k;
          if (s[x] == '1') {
            s[x] = '0';
            s[i] = '1';
            k = 0;
          }
        }
      }
    }
    cout << s << "\n";
  }
  return 0;
}
