#include <bits/stdc++.h>
using namespace std;
long long int n, k, q;
string s;
void solve() {
  set<int> zero, one;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0')
      zero.insert(i);
    else
      one.insert(i);
  }
  while (k > 0 && zero.size() > 0 && one.size() > 0) {
    auto it0 = zero.begin(), it1 = one.begin();
    if (*it0 < *it1)
      zero.erase(zero.begin());
    else {
      long long int Lagbe = *it0 - *it1;
      one.erase(*it0 - min(Lagbe, k));
      one.insert(*it0);
      zero.erase(zero.begin());
      k -= Lagbe;
    }
  }
  vector<int> v(n, 0);
  for (auto it : one) v[it] = 1;
  for (auto it : v) cout << it;
  cout << '\n';
}
int main() {
  cin >> q;
  while (q--) {
    cin >> n >> k;
    cin >> s;
    solve();
  }
  return 0;
}
