#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for (int i = 0, j = 0; i < n; ++i) {
      j = max(i, j);
      while (j < n && s[j] != '0') j++;
      if (j < n && k >= j - i) {
        swap(s[i], s[j]);
        k -= j - i;
      }
    }
    cout << s << "\n";
  }
  return 0;
}
