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