#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5, mod = 1e9 + 7, mod1 = 998242353, mod2 = 1e9 + 9,
                inf = 1e9 + 7;
const long long infll = 1e18 + 7;
long long n, m, k;
long long q = 1, sum, ans, tmp, cur, res, idx;
long long x, y, z;
string s, t;
vector<long long> a;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  while (q--) {
    a.clear();
    cin >> n >> k;
    cin >> s;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '0') {
        a.push_back(i);
      }
    }
    for (long long i = 0; i < a.size(); i++) {
      swap(s[a[i]], s[a[i] - min(k, a[i] - i)]);
      k -= min(k, a[i] - i);
      if (k == 0) break;
    }
    cout << s << '\n';
  }
}
