#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<long long> v;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '0') {
        v.push_back(i);
      }
    }
    long long p = 0;
    for (long long i = 0; i < v.size(); i++) {
      if (v[i] - p < k) {
        k -= v[i] - p;
        v[i] = p;
        p++;
      } else {
        v[i] = v[i] - k;
        k = 0;
        break;
      }
    }
    string ans = "";
    long long c = 0;
    for (long long i = 0; i < v.size(); i++) {
      while (v[i] > c) {
        ans += '1';
        c++;
      }
      ans += '0';
      c++;
    }
    while (ans.size() < n) {
      ans += '1';
    }
    cout << ans << endl;
  }
}
