#include <bits/stdc++.h>

using namespace std;

const int Inf = 1e6 + 13;

void inverse(string& s)
{
    for (auto& el : s)
    {
        el = ('1' - el) + '0';
    }
}

string in2(int value, int len)
{
    string answer(len, '0');
    for (auto rit = answer.rbegin(); rit != answer.rend(); ++rit)
    {
        *rit = (value & 1) + '0';
        value >>= 1;
    }
    return answer;
}

void test()
{
    int n, k; cin >> n >> k;
    string s; cin >> s;
    inverse(s);
    int m = min(k, 20);
    int pow = 0;
    static auto number = [](char c) { return c - '0'; };
    unordered_set<int> st{};
    vector<int> ones({ -1 });
    for (int i = 0; i < n; ++i)
    {
        if (number(s[i]) == 1)
            ones.push_back(i);
    }
    auto leftOne = [&](int pos)
    {
        int l = 0, r = ones.size();
        while (r - l > 1)
        {
            int m = (l + r) >> 1;
            if (ones[m] > pos)
                r = m;
            else
                l = m;
        }
        if (r < ones.size() && ones[r] <= pos)
            return r;
        return l;
    };
    auto hasOne = [&](int left, int right)
    {
        if (left > right) return false;
        if (ones.empty())
            return false;
        if (s[left] == '1' || s[right] == '1')
            return true;
        return (leftOne(left) != leftOne(right));
    };
    for (int i = k - 1; i < n; ++i)
    {
        int pow = 0;
        for (int j = i - m + 1; j <= i; ++j)
        {
            pow = pow * 2 + number(s[j]);
            if (pow > Inf)
            {
                pow = Inf; break;
            }
        }
        if (!hasOne(i - k + 1, i - m))
        {
            st.insert(pow);
        }
    }
    int answer = 0, max = 1 << m;
    while (answer < max)
    {
        if (st.find(answer) == st.end())
        {
            cout << "YES\n" << in2(answer, k) << endl;
            return;
        }
        ++answer;
    }
    cout << "NO\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int q; cin >> q;
    while (q--)
        test();
    return 0;
}
