#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  int T;
  cin >> T;
  while (T--) {
    long long int t, n, i, j, x, y, m, l, d, k;
    cin >> n >> k;
    string str;
    cin >> str;
    vector<long long int> v;
    for (i = 0; i < (n); ++i) {
      if (str[i] == '0') v.push_back(i);
    }
    long long int curr = 0;
    for (i = 0; i < (v.size()); ++i) {
      if (v[i] - curr < k) {
        k -= (v[i] - curr);
        v[i] = curr;
        curr++;
      } else {
        v[i] = v[i] - k;
        k = 0;
        break;
      }
    }
    vector<long long int> ans(n, 1);
    for (i = 0; i < (v.size()); ++i) ans[v[i]] = 0;
    for (i = 0; i < (n); ++i) cout << ans[i];
    cout << "\n";
  }
}
