#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q;
  cin >> q;
  while (q--) {
    long long n, k;
    string s;
    cin >> n >> k >> s;
    priority_queue<long long, vector<long long>, greater<long long>> zero, one;
    for (long long i = 0; i < s.size(); ++i) {
      if (s[i] == '0')
        zero.push(i);
      else
        one.push(i);
    }
    long long c = 0;
    while (!zero.empty() && !one.empty()) {
      long long a = zero.top();
      long long b = one.top();
      if (a > b) {
        if (c + (a - b) <= k) {
          swap(s[a], s[b]);
          c = c + (a - b);
          zero.pop();
          one.pop();
          one.push(a);
        } else {
          one.pop();
        }
      } else {
        zero.pop();
      }
    }
    cout << s << '\n';
  }
  return 0;
}
