#include <bits/stdc++.h>
using namespace std;
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};
string s;
long long n;
int next(int i) {
  for (int j = i; j < n; j++) {
    if (s[j] == '1') return j;
  }
  return n;
}
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    long long k;
    cin >> n >> k >> s;
    long long idx = -1;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '0') {
        if (idx > i) continue;
        idx = next(idx);
        if (idx > i) continue;
        long long need = i - idx;
        if (need <= k) {
          swap(s[i], s[idx]);
          k -= need;
        } else {
          swap(s[i], s[i - k]);
          k = 0;
        }
      }
    }
    cout << s << endl;
  }
}
