#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  string str;
  cin >> str;
  string res;
  long long count = 0;
  bool print = false;
  for (long long i = 0; i < n; i++) {
    if (str[i] == '0') {
      if (count <= k) {
        res += '0';
        k -= count;
      } else {
        res += string(count - k, '1');
        res += '0';
        res += string(k, '1');
        res += str.substr(i + 1);
        cout << res << "\n";
        print = true;
        break;
      }
    } else {
      count++;
    }
  }
  if (!print) {
    res += string(count, '1');
    cout << res << "\n";
  }
}
