#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF = 200000000000000;
double pi = 3.141592653589793;
const int MOD = 1000000007;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(a % b, b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long myPow(long long x, long long n, long long m = MOD) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
class Point {
 public:
  long long x;
  long long y;
  long long dis;
  Point(long long _x, long long _y, long long _dis) {
    x = _x;
    y = _y;
    dis = _dis;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long Q;
  cin >> Q;
  for (int q = 0; q < Q; q++) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int num0 = 0;
    for (int i = 0; i < n; i++) {
      if (k <= 0) break;
      if (s[i] == '0') {
        int num = i - num0;
        if (num < k) {
          swap(s[num0], s[i]);
        } else {
          swap(s[i - k], s[i]);
        }
        num0++;
        k -= num;
      }
    }
    cout << s << endl;
  }
}
