#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    long long int i, j, k, n;
    cin >> n >> k;
    string s;
    cin >> s;
    int flag = 0;
    j = -1;
    vector<long long int> v1, v0;
    for (i = 0; i < n; i++) {
      if (s[i] == 48 && flag == 0) j = i;
      if (s[i] == 48) v0.push_back(i);
      if (s[i] == 49) {
        v1.push_back(i);
        flag = 1;
      }
    }
    if (flag == 0) {
      cout << s << "\n";
      continue;
    }
    long long int cnt = 0;
    cnt = j + 1;
    for (i = 0; i < v0.size(); i++) {
      if (v0[i] > j) {
        while (cnt < n && s[cnt] == 48) cnt++;
        long long int x;
        x = k - (v0[i] - cnt);
        if (x >= 0) {
          k = k - (v0[i] - cnt);
          char c;
          c = s[v0[i]];
          s[v0[i]] = s[cnt];
          s[cnt] = c;
          cnt++;
        } else {
          long long int l = v0[i] - k;
          while (l < v0[i] && s[l] == 48) l++;
          char c;
          c = s[v0[i]];
          s[v0[i]] = s[l];
          s[l] = c;
          cnt++;
          break;
        }
      }
    }
    cout << s << "\n";
  }
}
