#include<bits/stdc++.h>

using namespace std;

#define loop(i, l, r) for(int i = (int) l; i <= (int) r; i++)
#define rloop(i, r, l) for(int i = (int) r; i >= (int) l; i--)

#define vi vector<int> 
#define ii pair<int, int> 
#define eb emplace_back
#define all(x) begin(x), end(x)
#define fi first
#define se second

#define rand rng
#define endl '\n'
#define sp ' '

const int maxN = 1e6 + 5;
int tc, N, K, trueK; 
bool in[1 << 25];
int pf0[maxN];
int ans = -1;
string s;
signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> tc;
	while(tc--)
	{
		cin >> N >> trueK >> s;
		K = 1;
		ans = -1;
		while((1 << K) <= 4 * N)
		{
			K++;
		}
		if(K > trueK)
		{
			K = trueK;
		}
		loop(val, 0, (1 << K) - 1) in[val] = 0;
		loop(i, 1, N)
		{
			pf0[i] = pf0[i - 1] + (s[i - 1] == '0');
		}
		loop(e, trueK, N)
		{
			if(pf0[e - K] - pf0[e - trueK]) continue;
			int val = 0;
			loop(i, e - K + 1, e)
			{
				val = val * 2 + (s[i - 1] - '0' ^ 1);
			}
			in[val] = 1;
		}
		loop(val, 0, (1 << K) - 1)
		{
			if(!in[val])
			{
				ans = val;
				break;
			}
		}
		if(ans == -1) 
		{
			cout << "NO" << endl;
		}
		else
		{
			cout << "YES" << endl;
			loop(i, 1, trueK - K)
			{
				cout << 0;
			}
			rloop(bit, K - 1, 0)
			{
				cout << (ans >> bit & 1);
			}
			cout << endl;
		}
	}
}