#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    map<int, int> mp;
    long long n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == '1') continue;
      int num = i - ans;
      if (k >= num) {
        k -= num;
        mp[ans] = 1;
        ans++;
      } else {
        if (k != 0) {
          mp[i - k] = 1;
          k = 0;
        } else {
          mp[i] = 1;
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      if (mp[i] == 1)
        cout << 0;
      else
        cout << 1;
    }
    cout << endl;
  }
  return 0;
}
