#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k, o = 0, tot = 0, f = 0;
  cin >> n >> k;
  char s[n];
  long long i = 0;
  for (i = 0; i < n; i++) {
    cin >> s[i];
    if (s[i] == '0') {
      if (i - o <= k) {
        char y = s[i];
        s[i] = s[o];
        s[o] = y;
        k -= i - o;
      } else {
        char u = s[i];
        s[i] = s[i - k];
        s[i - k] = u;
        k = 0;
      }
      o++;
    }
  }
  for (__typeof((n)) i = (0); i != (n); i++) cout << s[i];
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
