#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--, q > -1) {
    int n;
    long long int k;
    cin >> n >> k;
    vector<int> v;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
      if (s[i] == '0') v.push_back(i);
    int begin = 0, qtd = 0;
    while (k > 0 && qtd < v.size() && begin < n) {
      int dist = v[qtd] - begin;
      if (dist <= k)
        k -= dist, v[qtd] = begin, begin++;
      else
        v[qtd] -= k, begin = v[qtd] + 1, k = 0;
      qtd++;
    }
    for (int i = 0, j = 0; i < n; i++) {
      if (j < v.size() && i == v[j]) {
        cout << 0;
        j++;
      } else
        cout << 1;
    }
    cout << endl;
  }
}
