//In the name of Allah.
#include<bits/stdc++.h>
using namespace std;

const int N = 1e6 + 1, K = 20;
int n, k, T;
string s;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> T;
    while (T--) {
        cin >> n >> k >> s;
        map <int, bool> vis;
        for (int i = 0, j = 0; i + k <= n; i++, j = max(j, i)) {
            while (j < n && s[j] ^ '0')
                j++;
            if (i + k - K <= j) {
                int t = 0;
                for (int l = max(i + k - K, i); l < i + k; l++)
                    t += ('1' != s[l]) * (1 << i + k - l - 1);
                vis[t] = 1;
            }
        }
        int check = 1;
        for (int mask = 0; check && (k >= K || (k < K && mask < 1ll << k)); mask++)
            if (!vis[mask]) {
                string ans = "";
                for (int i = 0; i < k; i++)
                    ans += (i < K? 1 << i & mask? "1": "0": "0");
                reverse(ans.begin(), ans.end());
                cout << "YES" << endl << ans << endl;
                check = 0;
            }
        if (check)
            cout << "NO" << endl;
    }
}