#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
long long t, l, i, j, k, p, q, u, v, n, color[1000005];
string s;
vector<long long> zro;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  for (l = 1; l <= q; l++) {
    cin >> n >> k >> s;
    for (i = 0; i < n; i++) {
      if (s[i] == '0')
        zro.push_back(i);
      else
        color[i] = 1;
    }
    u = 0;
    v = 0;
    for (i = 0; i < zro.size(); i++) {
      if (u == n || k == 0) break;
      for (; u < n; u++) {
        if (zro[i] < u) break;
        if (color[u] == 1 && zro[i] - u <= k) {
          k -= (zro[i] - u);
          color[zro[i]] = 1;
          color[u] = 0;
          swap(s[u], s[zro[i]]);
          u++;
          break;
        }
      }
    }
    cout << s << endl;
    for (i = 0; i <= n; i++) color[i] = 0;
    zro.clear();
  }
  return 0;
}
