#include <bits/stdc++.h>
using namespace std;
int n;
long long k;
char second[2000002];
inline void solve() {
  scanf(
      "%d"
      "%lld",
      &n, &k);
  scanf("%s", second);
  for (int i = 0, j = 0; i < n && k; ++i) {
    if (second[i] == '1') continue;
    long long t = min(k, 1LL * i - j);
    int pos = i - t;
    swap(second[i], second[pos]);
    k -= t;
    ++j;
  }
  puts(second);
}
int main() {
  int tt;
  scanf("%d", &tt);
  for (int t = 0; t < tt; ++t) solve();
  return 0;
}
