#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef string str;
typedef double db;
typedef long double ld;

typedef pair<int, int> pi;
typedef  pair<ll, ll> pl;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;


#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FR(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define RF(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) int((x).size())
int timer = 1;
int seen[(1<<20)];
int main() {
    cin.tie(0)->sync_with_stdio(0);
    int Q;
    cin >> Q;
    iter:
    while (Q-->0) {
        int N, K;
        cin >> N >> K;
        str s;
        cin >> s;
        int last = -1;
        int k2 = min(K, 20);
        int msk = (1<<k2)-1;
        int cur = 0;
        for (int i = 0; i < N; i++) {
            cur *= 2;
            cur += (1-((s[i]=='0')? 0 : 1));
            if (i >= K) {
                cur&=msk;
            }
            if (i >= k2) {
                if (s[i-k2] == '0') {
                    last = i-k2;
                }
            }
            if (i >= K-1) {
                if (last < i-K+1) {
                    seen[cur] = timer;
                }
            }
        }
        for (int i = 0; i < (1<<k2); i++) {
            if (seen[i] != timer) {
                cout << "YES" << '\n';
                for (int j = 0; j < K-k2; j++) {
                    cout << '0';
                }
                for (int j = k2-1; j >=0; j--) {
                    cout << ((i&(1<<j))>>j);
                }
                cout << '\n';
                timer++;
                goto iter;
            }
        }
        cout << "NO" << '\n';
        timer++;
    }
}
