#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
long long binpow(long long int a, int b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a % mod) % mod;
    a = (a % mod * a % mod) % mod;
    b >>= 1;
  }
  return res;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    string a;
    cin >> a;
    int idx = 0;
    while (a[idx] == '0') {
      idx++;
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == '0' && i > idx) {
        int diff = i - idx;
        if (diff < k) {
          k -= diff;
          a[i] = '1';
          a[idx] = '0';
          while (a[idx] == '0' && idx < n - 1) idx++;
        } else {
          while (i - k >= 0 && a[i - k] == '0' && k > 0) k--;
          a[i] = '1';
          a[i - k] = '0';
          break;
        }
      }
      if (k <= 0) break;
    }
    for (int i = 0; i < n; i++) cout << a[i];
    cout << endl;
  }
}
