#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n, rec = 0;
    long long int k;
    cin >> n >> k;
    char str[1000005];
    cin >> str;
    for (int h = 0; h < n; h++, rec++) {
      int pos = h;
      for (int i = h; i < n; i++) {
        if (str[i] == '0') {
          pos = i;
          break;
        }
      }
      h = pos;
      if (k - pos - rec >= 0) {
        char temp = str[pos];
        str[pos] = str[rec];
        str[rec] = temp;
        k -= (pos - rec);
      } else if (k > 0) {
        while (pos > 0 && str[pos - 1] == '1' && k > 0) {
          char temp = str[pos];
          str[pos] = str[pos - 1];
          str[pos - 1] = temp;
          pos--;
          k--;
        }
      }
    }
    cout << str << endl;
  }
  return 0;
}
