#include <bits/stdc++.h>
using namespace std;
void swap(char &a, char &b) {
  char t = a;
  a = b;
  b = t;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) {
    long long n, first;
    cin >> n >> first;
    string str;
    cin >> str;
    long long pre1 = -1;
    long long t = 0;
    for (int i = 0; i < str.size(); i++) {
      if (t == first) break;
      if (str[i] == '0') {
        if (pre1 == -1)
          continue;
        else {
          long long dist = i - pre1;
          if (dist + t <= first)
            swap(str[pre1], str[i]), pre1++, t += dist;
          else
            swap(str[i - (first - t)], str[i]), t = first;
        }
      } else {
        if (pre1 == -1) pre1 = i;
      }
    }
    cout << str << "\n";
  }
  return 0;
}
