#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n, k, c = 0, arr[1000000];
    cin >> n >> k;
    string s;
    cin >> s;
    for (long long i = 0; i < s.size(); i++) {
      if (s[i] == '0') {
        arr[c] = i;
        c++;
      }
    }
    if (c != 0) {
      for (int i = 0; i < s.size() && i < c; i++) {
        if (k == 0)
          break;
        else if (arr[i] - i <= k) {
          s[arr[i]] = '1';
          s[i] = '0';
          k -= arr[i] - i;
        } else {
          s[arr[i]] = '1';
          s[arr[i] - k] = '0';
          break;
        }
      }
    }
    cout << s << "\n";
  }
  return 0;
}
