#include <bits/stdc++.h>
using namespace std;
long long n, t, m, l1, l2, l3, l, p, c, r, k;
long long sum, mi = 1000010, ma, cnt, num, tot, res;
long long a[1000010], b[1000010];
signed main() {
  cin >> t;
  while (t--) {
    cnt = 0;
    cin >> n >> k;
    char s[n + 1];
    cin >> s;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '0') {
        if (k > (i - cnt)) {
          swap(s[i], s[cnt]);
          k -= i - cnt;
          cnt++;
        } else {
          swap(s[i], s[i - k]);
          break;
        }
      }
    }
    cout << s << endl;
  }
  return 0;
}
