#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    long long minPosCero = 0;
    vector<bool> moved(n, false);
    while (minPosCero < s.size() && s[minPosCero] == '0') {
      moved[minPosCero] = true;
      minPosCero++;
    }
    long long pos = -1;
    for (long long i = minPosCero; i < s.size(); i++) {
      if (s[i] == '0') {
        if (i - minPosCero <= k) {
          k -= (i - minPosCero);
          moved[i] = true;
          minPosCero++;
        } else {
          pos = i;
          break;
        }
      }
    }
    vector<int> res(minPosCero, 0);
    for (long long i = 0; i < n; i++) {
      if (!moved[i]) {
        res.push_back(s[i] - '0');
      }
    }
    if (pos >= 0) {
      long long i = pos;
      if (i < res.size()) {
        while (i > 0 && k > 0) {
          swap(res[i], res[i - 1]);
          i--;
          k--;
        }
      }
    }
    for (int j = 0; j < res.size(); j++) cout << res[j];
    cout << endl;
  }
  return 0;
}
