#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1, c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template <class A>
string to_string(complex<A> c) {
  stringstream second;
  second << c;
  return second.str();
}
string to_string(vector<bool> v) {
  string res = "{";
  for (int i = 0; i < v.size(); ++i) res += char('0' + v[i]);
  res += "}";
  return res;
}
template <size_t SZ>
string to_string(bitset<SZ> b) {
  string res = "";
  for (int i = 0; i < SZ; ++i) res += char('0' + b[i]);
  return res;
}
template <class A, class B>
string to_string(pair<A, B> p);
template <class T>
string to_string(T v) {
  bool fst = 1;
  string res = "{";
  for (const auto& x : v) {
    if (!fst) res += ", ";
    fst = 0;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <class A, class B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void DBG() { cerr << "]" << endl; }
template <class H, class... T>
void DBG(H h, T... t) {
  cerr << to_string(h);
  if (sizeof...(t)) cerr << ", ";
  DBG(t...);
}
void EDBG(string names) { names = names; }
template <class H, class... T>
void EDBG(string names, H h, T... t) {
  auto pos = names.find(',');
  auto first_name = names.substr(0, pos);
  auto rest = names.substr(pos + 1);
  while (rest.front() == ' ') {
    rest = rest.substr(1);
  }
  cerr << "   [" << first_name << "]: [" << to_string(h) << "]" << endl;
  EDBG(rest, t...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t, cnt = 1;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string a, b;
    for (int i = 0; i < n; i++) b.push_back(0);
    cin >> a;
    long long j = 0, ones = 0, up = -1;
    for (int i = 0; i < n; i++) {
      if (a[i] == '0') {
        up = i;
        if (ones <= k) {
          k -= ones;
          b[j++] = '0';
        } else {
          b[max(j, i - k)] = '0';
          break;
        }
      } else
        ones++;
    }
    for (int i = 0; i < up + 1; i++)
      if (b[i] == 0) b[i] = '1';
    for (int i = up + 1; i < n; i++) b[i] = a[i];
    cout << b << '\n';
  }
  return 0;
}
