#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5, OO = 1e9 + 5;
const int di[] = {1, -1, 0, 0};
const int dj[] = {0, 0, 1, -1};
long long TC, n, m, k, l, mn, cnt, ans, arr[N];
bool f, vis[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> TC;
  while (TC--) {
    string s;
    cin >> n >> k >> s;
    l = 0;
    for (int i = 0; i < n; ++i)
      if (s[i] == '0') {
        mn = min(k, i - l);
        swap(s[i], s[i - mn]);
        l++;
        k -= mn;
      }
    cout << s << "\n";
  }
  return 0;
}
