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

char s[1000005];
int pre[1000005];
map<int,int>mp;
int main()
{
    int q,n,k,m;
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d%d",&n,&k);
        m=0;
        mp.clear();
        while(m<k&&(1<<m)<=n)
            m++;
        scanf("%s",s+1);
        //cout<<"yes"<<endl;
        for(int i=1; i<=n; i++)
            s[i]=1-s[i]+2*'0';
        for(int i=1; i<=n; i++)
            pre[i]=pre[i-1]+(s[i]=='1');
        for(int i=1; i<=n-k+1; i++)
        {
            if(pre[i-1]!=pre[i+k-m-1])
                continue;
            int tmp=0;
            for(int j=i+k-1; j>=i+k-m; j--)
                if(s[j]=='1')
                    tmp^=(1<<(i+k-1-j));
            mp[tmp]=1;
        }

        int ans=0;
        while(ans<(1<<m)&&mp[ans])
            ans++;
        //cout<<ans<<endl;
        if(ans==(1<<m))
            printf("NO\n");
        else
        {
            printf("YES\n");
            string str;
            while(ans)
            {
                str+=((ans%2)+'0');
                ans/=2;
            }
            while(str.length()<k)
                str+='0';
            reverse(str.begin(),str.end());
            cout<<str<<endl;
        }
    }
}
