#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    string s;
    cin >> n >> k;
    vector<int> v;
    cin >> s;
    bitset<1000010> b;
    for (int i = 0; i < n; ++i) {
      if (s[i] == '0') {
        v.push_back(i);
      }
    }
    int count = 0, last = -1, zero = 0;
    for (auto i : v) {
      if (k >= (i - count)) {
        b[i] = 1;
        zero++;
      } else
        break;
      k -= (i - count);
      count++;
    }
    int z = zero;
    string res = "";
    while (zero--) {
      res += '0';
    }
    for (int i = 0; i < s.size(); ++i) {
      if (b[i]) continue;
      res += s[i];
    }
    for (int j = z; j < res.size(); j++) {
      if (res[j] == '0') {
        int p = j;
        while (k-- && p > 0) {
          char tmp = res[p];
          res[p] = res[p - 1];
          res[p - 1] = tmp;
          p--;
        }
        break;
      }
    }
    cout << res << endl;
  }
}
