#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long mod1 = 998244353;
const long long inf = 92233720000000000ll;
void solve() {
  long long n, k;
  string s;
  cin >> n >> k >> s;
  string ans, pre;
  for (long long i = (0); i < (n); i++) {
    if (s[i] == '1')
      pre += '1';
    else if (pre.empty())
      ans += '0';
    else if ((long long)pre.size() <= k) {
      ans += '0';
      k -= (long long)(pre.size());
    } else {
      long long len2 = k;
      long long len1 = (long long)pre.size() - len2;
      ans += pre.substr(0, len1);
      ans += '0';
      ans += pre.substr(len1, len2);
      ans += s.substr(i + 1, n - i);
      pre.clear();
      break;
    }
  }
  ans += pre;
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
