#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
const int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int64_t n, k;
    cin >> n >> k;
    string s, ans;
    cin >> s;
    vector<int64_t> pos;
    for (int i = 0; i < s.length(); ++i)
      if (s[i] == '0') pos.push_back(i);
    int last = 0, idx = 0;
    for (int i = 0; i < pos.size(); ++i) {
      if (k <= 0) continue;
      k -= abs(pos[i] - last), pos[i] = last++;
      if (k <= 0) idx = i;
    }
    if (k < 0) pos[idx] += abs(k);
    while (n--) ans += '1';
    for (int64_t i : pos) ans[i] = '0';
    cout << ans << '\n';
  }
  return 0;
}
