#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long MM = 998244353;
const long long mod = 1e9 + 7;
const long long INF = 1e9 + 5;
const long long N = 5e6 + 4;
void solve() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<pair<long long, long long>> pos;
  long long initial = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '0') {
      long long steps_req = i - initial;
      if (steps_req <= k) {
        k -= steps_req;
        pos.push_back(make_pair(i, initial));
      } else {
        long long new_pos = i - k;
        k = 0;
        pos.push_back({i, new_pos});
      }
      initial++;
    }
  }
  vector<long long> fresh;
  for (pair<long long, long long> x : pos) {
    fresh.push_back(x.second);
  }
  sort(fresh.begin(), fresh.end());
  string ans(n, '?');
  for (long long &x : fresh) {
    ans[x] = '0';
  }
  for (char &ch : ans) {
    if (ch == '?') {
      ch = '1';
    }
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
