#include <bits/stdc++.h>
using namespace std;
int q, n, a[1000005];
long long k;
int main() {
  int q, i, p;
  cin >> q;
  for (; q; --q) {
    cin >> n >> k;
    for (i = 1; i <= n; ++i) {
      char chr;
      cin >> chr;
      a[i] = chr - '0';
    }
    p = 0;
    for (i = 1; i <= n; ++i)
      if (a[i] == 0) {
        p = max(1ll * p + 1, 1ll * i - k);
        k -= i - p;
        swap(a[i], a[p]);
      }
    for (i = 1; i <= n; ++i) cout << a[i];
    cout << '\n';
  }
  return 0;
}
