#include <bits/stdc++.h> 
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define rfr(i, n, m) for(int i = (n); i >= (m); i --)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
#include <time.h>
#include <cmath>
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,int> pii;
const int i_inf = 1e9;
const ll inf = 1e18;
const ll mod = 1e9+7;
const ld eps = 1e-13;
const ld pi  = 3.14159265359;
const int mxn = 3e5+5;
mt19937 _rand(time(NULL));
clock_t z;


bool used[(1<<22)];
void solve(){
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int zer[n+1];
	zer[0] = 0;
	fr(i, 1, n+1){
		zer[i] = zer[i-1];
		if(s[i-1] == '0') zer[i] = i;
	}
	
	
	fr(i, k, n+1){
		if(zer[i] <= i-k){
			used[0] = true;
		}
		int mask = 0;
		for(int j = i, pos = 0; j >= 1 && pos < 22; j --, pos++){
			if(s[j-1] == '0') mask |= (1<<pos);
			if(zer[j-1] <= i-k){
				used[mask] = true;
			} 
		}
	}
	int ans = -1;
	
	int bo = n+10;
	if(k < 25) bo = min(bo, (1<<k));
	
	fr(i, 0, bo){
		if(used[i]) continue;
		ans = i;
		break;
	}
	
	fr(i, k, n+1){
		if(zer[i] <= i-k){
			used[0] = false;
		}
		int mask = 0;
		for(int j = i, pos = 0; j >= 1 && pos < 22; j --, pos++){
			if(s[j-1] == '0') mask |= (1<<pos);
			if(zer[j-1] <= i-k){
				used[mask] = false;
			} 
		}
	}
	if(ans == -1){
		cout<<"NO"<<endl;
		return;
	}
	else{
		cout<<"YES"<<endl;
		string sol = "";
		int lst = 0;
		fr(i, 0, 22){
			if(ans & (1<<i)){
				lst = i+1;
			}
		}
		fr(i, 0, lst){
			if(ans & (1<<i)){
				sol += '1';
			}
			else{
				sol += '0';
			}
		}
		fr(i, lst, k){
			sol += '0';
		}
		reverse(sol.begin(), sol.end());
		cout<<sol<<endl;
	}
	
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tc = 1;
	cin >> tc;
	while(tc--){
		solve();
	}

}
 
