#include <bits/stdc++.h>
using namespace std;
long long n, m, i, k, x, y, z, j;
string s;
int main() {
  cin >> n;
  for (j = 0; j < n; j++) {
    cin >> m >> y >> s;
    z = 0;
    x = 0;
    for (i = 0; i < m; i++) {
      if (s[i] == '0' && x > 0) {
        if (i - z <= y) {
          y -= i - z;
          s[z] = '0';
          s[i] = '1';
          z++;
        } else {
          s[i - y] = '0';
          s[i] = '1';
          y = 0;
        }
      } else if (s[i] == '0')
        z++;
      else
        x++;
      if (y == 0) break;
    }
    cout << s << endl;
  }
}
