#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  int n, m, t;
  int x, y, q, r;
  long long int k;
  string s;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    scanf("%I64d", &k);
    cin >> s;
    vector<pair<int, int> > vec;
    if (n == 1) {
      cout << s << endl;
      continue;
    }
    string ans;
    long long int uno = 0;
    bool flag = false;
    for (i = 0; i < n; i++) {
      if (s[i] == '1')
        uno++;
      else {
        if (k >= uno)
          ans.push_back('0'), k -= uno;
        else {
          x = uno - k;
          while (x--) ans.push_back('1');
          ans.push_back('0');
          while (k--) ans.push_back('1');
          for (j = i + 1; j < n; j++) ans.push_back(s[j]);
          flag = true;
          break;
        }
      }
      if (flag)
        break;
      else if (i == n - 1 && uno) {
        while (uno--) ans.push_back('1');
      }
    }
    cout << ans << endl;
  }
  return 0;
}
