#include <bits/stdc++.h>
using namespace std;
int main() {
  long long q;
  scanf("%lld", &q);
  while (q--) {
    long long n, k;
    scanf("%lld %lld", &n, &k);
    char arr[n + 1], sol[n + 1];
    for (int i = 0; i < n; i++) sol[i] = '1';
    sol[n] = 0;
    scanf("%s", arr);
    long long len = strlen(arr);
    vector<long long> pos;
    for (int i = 0; i < len; i++) {
      if (arr[i] == '0') pos.emplace_back(i);
    }
    long long curr = 0;
    for (long long x : pos) {
      if (x == curr) {
        sol[curr] = '0';
        curr++;
      } else if (x - curr <= k && x != curr && k) {
        sol[curr] = '0';
        k -= x - curr;
        curr++;
      } else if (x != curr && k) {
        long long y = x - curr - k;
        sol[curr + y] = '0';
        k = 0;
      } else if (!k)
        sol[x] = '0';
    }
    printf("%s\n", sol);
  }
  return 0;
}
