#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 10;
const int INF = 0x3f3f3f3f;
const int inf = -INF;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
void swap(int &a, int &b) {
  int c = a;
  a = b;
  b = c;
}
char s[N];
int main() {
  int Q;
  scanf("%d", &Q);
  while (Q--) {
    int n;
    long long k;
    scanf("%d%lld", &n, &k);
    scanf("%s", s);
    int pos = 0;
    for (int i = 0; i < n; i++) {
      if (k <= 0) break;
      if (s[i] == '0') {
        if (k - i + pos > 0) {
          swap(s[i], s[pos]);
          k = k - i + pos;
        } else {
          int t = i - k;
          swap(s[i], s[t]);
          k = 0;
        }
        pos++;
      }
    }
    printf("%s\n", s);
  }
  return 0;
}
