#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &x) {
  x = 0;
  register char c = getchar();
  register bool f = 0;
  while (!isdigit(c)) f ^= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  if (f) x = -x;
}
template <class T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar('0' + x % 10);
}
void rd() {}
const int N = 1e6 + 9;
int T, n, m, x;
long long k;
vector<int> v;
bool vis[N];
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d %I64d", &n, &k);
    v.clear();
    for (int i = 1; i <= n; i++) {
      scanf("%1d", &x);
      vis[i] = false;
      if (x == 0) v.push_back(i);
    }
    int maxn = 1;
    for (int i = 0; i < v.size(); i++) {
      if (k == 0) {
        vis[v[i]] = true;
        continue;
      }
      if (k >= (v[i] - maxn)) {
        k -= (v[i] - maxn);
        vis[maxn] = true;
        maxn++;
      } else {
        vis[v[i] - k] = true;
        k = 0;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (vis[i])
        printf("0");
      else
        printf("1");
    }
    puts("");
  }
  return 0;
}
