#include <bits/stdc++.h>
using namespace std;
const long long N = 1e9;
const long long NN = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
template <typename T, typename T1>
T maxn(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T minn(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  string second;
  cin >> second;
  long long int ind[n];
  for (long long int(i) = 0; (i) < (n); (i)++) ind[i] = i;
  long long int cnt = 0;
  for (long long int(i) = 0; (i) < (n); (i)++) {
    if (!k) break;
    if (second[i] == '1') {
      while (second[i] == '1' && i < n) {
        i++;
        cnt++;
      }
      i--;
    } else if (second[i] == '0' && i != 0) {
      ind[i] -= min(cnt, k);
      k -= min(cnt, k);
      if (!k) break;
    }
  }
  string ans;
  for (long long int(i) = 0; (i) < (n); (i)++) ans += "1";
  for (long long int(i) = 0; (i) < (n); (i)++) {
    if (second[i] == '0') ans[ind[i]] = '0';
  }
  cout << ans << "\n";
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int testcase = 1;
  cin >> testcase;
  while (testcase--) solve();
  return 0;
}
