#include <bits/stdc++.h>
using namespace std;
string s, t;
long long T, n, k;
long long zer[2000005], zc;
int main() {
  cin >> T;
  while (T--) {
    zc = 0;
    cin >> n >> k;
    cin >> s;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '0') zer[zc++] = i;
    }
    for (long long i = 0; i < zc; i++) {
      if (k >= zer[i] - i) {
        k -= (zer[i] - i);
        zer[i] = i;
      } else {
        zer[i] -= k;
        k = 0;
      }
    }
    t = s;
    for (long long i = 0; i < n; i++) t[i] = '1';
    for (long long i = 0; i < zc; i++) t[zer[i]] = '0';
    cout << t << endl;
  }
  return 0;
}
