#include <bits/stdc++.h>

using namespace std;

int zero[1000005];
char s[1000005];
bool vis[2000005];

int main() {
    int T;
    scanf("%d", &T);

    while (T--) {
        int n, k;
        scanf("%d%d", &n, &k);
        scanf("%s", s);

        // 2^x > n - k + 1

        int x = 0;
        while ((1 << x) <= n - k + 1) x++;

        // only consider first x bits
        x = min(x, k);
        for (int i = 0; i < (1 << x); i++) vis[i] = 0;
        for (int i = 0; i < n; i++) {
            zero[i] = (s[i] == '0');
            if (i) zero[i] += zero[i - 1];
        }
        int cur = 0;

        for (int i = k - x; i < k; i++) {
            cur = cur * 2 + (1 - (s[i] - '0'));
        }
        if (zero[k - 1 - x] == 0) vis[cur] = 1;

        for (int i = k; i < n; i++) {
            cur = cur * 2 + (1 - (s[i] - '0'));
            cur &= (1 << x) - 1;
            if (zero[i - x] - zero[i - k] == 0) vis[cur] = 1;
        }

        int res = -1;

        for (int i = 0; i < (1 << x); i++) {
            if (!vis[i]) {
                res = i;
                break;
            }
        }

        if (res == -1) printf("NO\n");
        else {
            printf("YES\n");
            for (int i = 0; i < k - x; i++) printf("0");
            for (int i = x - 1; i >= 0; i--) {
                int d = (res & (1 << i)) > 0;
                printf("%d", d);
            }
            printf("\n");
        }
    }
}