#include <bits/stdc++.h>
using namespace std;
template <class T>
using V = vector<T>;
template <class T>
using Vv = vector<vector<T>>;
template <class T>
using Pq = priority_queue<T>;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tests;
  cin >> tests;
  string inp_str;
  for (int t = 0; t < tests; ++t) {
    long long n, k;
    cin >> n >> k;
    cin >> inp_str;
    V<char> inp(inp_str.begin(), inp_str.end());
    int cnt = 0;
    bool printed = false;
    for (int c = 0; c < n; ++c) {
      if (inp[c] == '0') {
        if (cnt <= k) {
          k -= cnt;
          cout << '0';
        } else {
          cout << string(cnt - k, '1');
          cout << '0';
          cout << string(k, '1');
          for (int k = c + 1; k < n; ++k) {
            cout << inp[k];
          }
          printed = true;
          cout << endl;
          k = 0;
          break;
        }
      } else {
        ++cnt;
      }
    }
    if (!printed) {
      cout << string(cnt, '1');
      cout << endl;
    }
  }
  return 0;
}
