#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define mkp make_pair
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define F first
#define S second
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
#define pb push_back

using namespace std;
int ceillog(int x)
{
    int y=0;
    while((1<<y)<x)
        y++;
    return y;
}


int main() {
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        string s;
        cin>>s;
        int m=min(k,ceillog(n-k+2));
        vector<int> next0(n,int(1e9));
        int d=k-m;
        if(s[n-1]=='0')
        {
            next0[n-1]=n-1;
        }
        for(int i=n-2;i>=0;i--)
        {
            if(s[i]=='0')
            {
                next0[i]=i;
            }
            else
            {
                next0[i]=next0[i+1];
            }
        }
        vector<bool> used((1<<m),0);
        for(int i=0;i<n-k+1;i++)
        {
            if(next0[i]-i<d)
                continue;
            else
            {
                int temp=0;
                for(int j=i+d;j<i+k;j++)
                {
                    temp=(temp*2)+(s[j]-'0');
                }
                used[((1<<(m))-1)^temp]=1;
            }
        }
        int ans=-1;
        for(int i=0;i<(1<<m);i++)
        {
            if(used[i]!=1)
            {
                ans=i;
                break;
            }
        }
        if(ans==-1)
        {
            cout<<"NO"<<endl;

        }
        else
        {
            cout<<"YES"<<endl;
            string t1,t2(d,'0');
            for(int i=0;i<m;i++)
            {
                t1.push_back('0'+(ans%2));
                ans/=2;
            }
            reverse(t1.begin(),t1.end());
            t2+=t1;
            cout<<t2<<endl;
          }
    }
    return 0;
}
