#include <bits/stdc++.h>
using namespace std;
long long fib[100001];
void fibonacci() {
  fib[0] = 1;
  fib[1] = 1;
  fib[2] = 2;
  for (long long i = 3; i <= 100000; i++) {
    fib[i] = fib[i - 1] + fib[i - 2];
    fib[i] = fib[i] % 1000000007;
  }
}
double dist(double x, double y, double a, double b) {
  return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}
void swap(long long* a, long long* b) {
  long long temp = *a;
  *a = *b;
  *b = temp;
}
char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                     'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                     's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    char c[n];
    vector<long long> zero;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '0') zero.push_back(i);
    }
    long long j = 0;
    for (long long i = 0; i < zero.size(); i++) {
      long long val = zero[i] - i;
      if (val <= k) {
        zero[i] = i;
        k -= val;
      } else {
        zero[i] = zero[i] - k;
        k = 0;
      }
    }
    for (long long i = 0; i < n; i++) c[i] = '1';
    for (long long i = 0; i < zero.size(); i++) c[zero[i]] = '0';
    for (long long i = 0; i < n; i++) cout << c[i];
    cout << endl;
  }
}
