#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long d, z, mn = 1000000001, mx, sum, k, pos, l, x, y, r, n, m, ans, a1, a2,
                a3;
int a[200002], b[200002];
bool ok[200002], ko;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> l;
  while (l) {
    --l;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> v;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == '0') v.push_back(i);
    }
    for (int i = 0; i < v.size(); ++i) {
      if (v[i] - i <= k) {
        k -= (v[i] - i);
        s[v[i]] = '1', s[i] = '0';
      } else {
        for (int j = v[i]; k > 0; --j) {
          --k;
          s[j] = '1', s[j - 1] = '0';
        }
      }
    }
    cout << "\n" << s;
  }
}
