#include <bits/stdc++.h>
using namespace std;
void dbg_out() { cerr << "\b\b]\n"; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << H << ", ";
  dbg_out(T...);
}
void solve() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> ones(n, 0), zeros(n, 0);
  for (int i = 0; i < n; ++i) {
    if (s[i] == '1')
      ones[i] = 1;
    else
      zeros[i] = 1;
    if (i) {
      ones[i] += ones[i - 1];
      zeros[i] += zeros[i - 1];
    }
  }
  vector<int> ans(n, 1);
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') {
      int mn = min(k, (long long)ones[i]);
      ans[i - mn] = 0;
      k -= mn;
    }
  }
  for (int i : ans) cout << i;
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
