#include<bits/stdc++.h>
using namespace std;
string doi(int a){
	string sol="";
	while (a>0) {
		int s=a%2;
		sol=to_string(s)+sol;
		a/=2;
	}
	return sol;
}
int main (){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int casi;
	cin>>casi;
	while (casi--){
		int n,k;
		cin>>n>>k;
		string s;
		cin>>s;
		int r=min(20,k);
		bitset<(int)2e6> v;
		vector<int> next(n);
		if (s[0]=='1') next[0]=-1;
		for (int i=1;i<n;i++){
			if (s[i]=='0') next[i]=i;
			else next[i]=next[i-1];
		}
		for (int i=s.size()-1;i-k+1>=0;i--){
			if (r<k&&next[i-r]>=i-k+1) continue;
			int tmp=0;
			for (int j=0;j<r;j++){
				tmp+=(('1'-s[i-j])<<j);
			}
			v[tmp]=true;
		}
		int id=0;
		while (v[id]) id++;
		string tmp=doi(id);
		if ((int)tmp.size()>k) {
			cout<<"NO\n";
			continue;
		}
		else cout<<"YES\n";
		int temp=tmp.size();
		while(temp<k){
		    ++temp;   
		    cout << 0;
		}
		cout<<tmp<<'\n';
	}
}