#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, i, k;
  string s;
  cin >> t;
  while (t--) {
    queue<int> q;
    set<int> m;
    cin >> n >> k >> s;
    for (i = 0; i < n; i++) {
      if (s[i] == '1')
        q.push(i);
      else {
        if (q.size()) {
          int p = q.front();
          q.pop();
          if (k >= (i - p))
            swap(s[p], s[i]), k -= (i - p), q.push(i);
          else {
            while (q.size()) {
              int p = q.front();
              q.pop();
              if (k >= (i - p)) {
                swap(s[p], s[i]), k -= (i - p), q.push(i);
                break;
              }
            }
          }
        }
      }
    }
    cout << s << endl;
  }
  return 0;
}
