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

int main()
{
    int t;
    cin >> t;
    
    while(t--)
    {
        int n , k;
        cin >> n >> k;
        string x;
        cin >> x;
        int pr[n+1];
        memset(pr ,0 , sizeof(pr));
        for(int i = 0 ; i < n ; i++)
        {
            if(x[i] == '1')
            pr[i+1] = pr[i]+1;
            else
            pr[i+1] = pr[i];
        }
        
        int kk = min((int)log2(n-k+1)+1 , k);
       //cout << kk << "\n";
        set<int>s;
        for(int i = 0; i < (1 << kk) ; i++)
        {
            s.insert(i);
        }
        
        
        for(int i = k ; i <= n ; i++)
        {
            int l = i-k;
            int r = i-kk;
            int cnt = pr[r] - pr[l];
            if(cnt == (k-kk))
            {
                int mask = 0;
                for(int j = i-kk+1 ; j <= i ; j++)
                {
                    if(x[j-1] == '0')
                    {
                        mask ^= (1 << (i-j));    
                    }
                }
              //  cout << i << " " << mask << "\n";
                s.erase(mask);
            }
        }
        
        if(s.size() == 0)
        {
            cout << "NO" << "\n";
            continue;
        }
        cout << "YES" << "\n";
        string ans;        
        int rem = *s.begin();
        for(int i = 0 ; i < k-kk ; i++)
        ans.push_back('0');
        
        string temp ;
        for(int i = 0 ; i  < kk ; i++)
        {
            int d = rem%2;
            rem /= 2;
            temp.push_back(d+48);
        }
        
        reverse(temp.begin() , temp.end());
        
        for(int i = 0 ; i < kk ; i++)
        ans.push_back(temp[i]);
        
        cout << ans << "\n";
        
    
        
        
    }
    
}