#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
char s[maxn];
long long num[maxn];
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, k, cnt = 0;
    scanf("%lld%lld", &n, &k);
    scanf("%s", s + 1);
    for (long long i = 1; i <= n; i++) {
      if (s[i] == '1')
        cnt++;
      else
        num[i] = cnt;
    }
    long long st = 0, j = 1, res = k;
    while (s[j] == '0') j++, st++;
    for (long long i = 1; i <= n; i++) {
      if (num[i]) {
        if (res >= (num[i])) {
          res = res - (num[i]);
          swap(s[st + 1], s[i]);
          st++;
        } else {
          swap(s[i], s[i - res]);
          break;
        }
      }
    }
    for (long long i = 1; i <= n; i++) {
      printf("%c", s[i]);
      num[i] = 0;
    }
    printf("\n");
  }
}
