#include <bits/stdc++.h>
using namespace std;
long long int sqr(long long int x) { return x * x; }
inline long long int add(long long int a, long long int b) {
  long long int c = a + b;
  if (c >= 1000000007) c -= 1000000007;
  return c;
}
inline long long int mul(long long int a, long long int b) {
  return (a * 1ll * b) % 1000000007;
}
inline long long int sub(long long int a, long long int b) {
  long long int c = a - b;
  if (c < 0) c += 1000000007;
  return c;
}
const int nax = 100 * 1000 + 5;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    string str;
    cin >> str;
    long long int cnt = 0;
    for (long long int i = 0; i < n; ++i) {
      if (str[i] == '0') {
        if (cnt == 0) continue;
        if (cnt < k) {
          str[i] = '1';
          str[i - cnt] = '0';
          k -= cnt;
        } else {
          str[i] = '1';
          str[i - k] = '0';
          break;
        }
      } else {
        cnt++;
      }
    }
    cout << str << "\n";
  }
  return 0;
}
