#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k, i, j, x;
    cin >> n >> k;
    string arr;
    cin >> arr;
    i = 0;
    while (i < n && arr[i] != '1') i++;
    j = i;
    for (; i < n; i++) {
      if (arr[i] == '0') {
        x = i - j;
        if (x <= k) {
          arr[j] = '0';
          arr[i] = '1';
          j++;
          k -= x;
        } else if (x > k) {
          arr[i - k] = '0';
          arr[i] = '1';
          k = 0;
        }
        if (k == 0) {
          break;
        }
      }
    }
    cout << arr << endl;
  }
  return 0;
}
