#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> mm;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j, n, k, t, ll;
  string s;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    cin >> s;
    i = 0;
    j = 0;
    while (j < n) {
      if (s[j] == '1')
        j++;
      else if (s[j] == '0') {
        ll = j - i;
        if (ll < k) {
          mm[i] = 1;
          k -= ll;
          i++;
          j++;
        } else {
          mm[j - k] = 1;
          break;
        }
      }
    }
    if (j >= n) j = n - 1;
    for (i = 0; i <= j; i++) {
      if (mm[i] == 1)
        cout << '0';
      else
        cout << '1';
    }
    for (i = j + 1; i < n; i++) cout << s[i];
    cout << '\n';
    mm.clear();
  }
  return 0;
}
