#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long m;
    cin >> m;
    vector<string> arr1;
    string s;
    cin >> s;
    for (long long i = 0; i < n; i++) {
      string a = to_string(i);
      if (s[i] == '0') arr1.push_back(a);
    }
    long long k = arr1.size();
    for (long long i = 0; i < k; i++) {
      if (i == 0) {
        long long temp = m - (stoi(arr1[i]));
        if (temp < 0) {
          arr1[i] = to_string(stoi(arr1[i]) - m);
          break;
        }
        m = m - stoi(arr1[i]);
        arr1[i] = '0';
        continue;
      }
      long long temp = m - (stoi(arr1[i]) - stoi(arr1[i - 1])) + 1;
      if (temp < 0) {
        arr1[i] = to_string(stoi(arr1[i]) - m);
        break;
      }
      m = temp;
      arr1[i] = to_string(stoi(arr1[i - 1]) + 1);
    }
    string arr2 = "";
    for (long long i = 0; i < n; i++) arr2.push_back(' ');
    for (long long i = 0; i < k; i++) arr2[stoi(arr1[i])] = '0';
    for (long long i = 0; i < n; i++)
      if (arr2[i] != '0')
        cout << 1;
      else
        cout << 0;
    cout << endl;
  }
}
