#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int64_t t = 1;
  cin >> t;
  while (t--) {
    int64_t n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int64_t pos = 0;
    for (int64_t i = 0; i < n; i++) {
      if (k == 0) break;
      if (s[i] == '0' && s[pos] == '0') {
        pos++;
        continue;
      }
      if (s[i] == '0') {
        if (k >= i - pos) {
          s[pos] = '0';
          s[i] = '1';
          k -= i - pos;
          pos++;
        } else {
          s[i - k] = '0';
          s[i] = '1';
          k -= i - k;
          break;
        }
      }
    }
    cout << s << '\n';
  }
  return 0;
}
