#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
long long vis[N];
vector<long long> adj[N + 1];
void dfs(long long u) {
  vis[u] = 1;
  for (auto i : adj[u]) {
    if (not vis[i]) {
      dfs(i);
    }
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<long long> v;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '0') v.push_back(i);
  }
  vector<long long> u;
  for (long long i = 0; i < (int)v.size(); i++) {
    u.push_back(v[i] - i);
  }
  long long ans[n];
  for (long long i = 0; i < n; i++) ans[i] = 1;
  for (long long i = 0; i < (int)u.size(); i++) {
    if ((k - u[i]) >= 0) {
      ans[i] = 0;
      k -= u[i];
    } else {
      long long kk = u[i] - k;
      ans[i + kk] = 0;
      k = 0;
    }
  }
  for (long long i = 0; i < n; i++) cout << ans[i];
  cout << '\n';
}
int main() {
  long long T = 1;
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> T;
  while (T--) solve();
  return 0;
}
