#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, l, m, n, q, r, t, x = 1, y, mid, ans;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> ze, on;
    for (i = 0; i < n; i++) {
      if (s[i] == '0')
        ze.push_back(i);
      else
        on.push_back(i);
    }
    ans = 0;
    while (ans < ze.size() && m >= ze[ans] - ans) {
      m -= (ze[ans] - ans);
      s[ze[ans]] = '1';
      s[ans] = '0';
      ans++;
    }
    if (m > 0 && ans < ze.size()) {
      s[ze[ans]] = '1';
      s[ze[ans] - m] = '0';
    }
    cout << s << "\n";
  }
  return 0;
}
