#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e6 + 10;
char s[N];
int a[N];
char t[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T;
    cin >> T;
    while (T--) {
        int n, k;
        cin >> n >> k;
        cin >> s;
        for (int i = 0; i < n; ++i) {
            a[i] = (i == 0 ? 0 : a[i - 1]) + (s[i] == '0');
        }
        set<int> da;
        for (int i = 0; i <= n - k; ++i) {
            int val = 0;
            if (k > 20 && a[i + k - 21] - (i == 0 ? 0 : a[i - 1]) > 0)
                continue;
            for (int j = max(i, i + k - 20), bs = 1; j < i + k; ++j) {
                val = val * 2 + (s[j] == '0');
            }
            da.emplace(val);
        }
        for (int i = 0; ; ++i) {
            if (k <= 20 && (1 << k) <= i) {
                cout << "NO" << endl;
                break;
            }
            if (da.find(i) != da.end())
                continue;
            int l = 0;
            for (int j = i; j; j /= 2) {
                t[l++] = j % 2 + '0';
            }
            for (; l < k && l < 20; ) {
                t[l++] = '0';
            }
            reverse(t, t + l);
            cout << "YES" << endl;
            for (int j = 0; j < k - l; ++j)
                cout << '0';
            for (int j = 0; j < l; ++j)
                cout << t[j];
            cout << endl;
            break;
        }
    }
}