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

int n, k, K;
char str[1000010];

void solve()
{
	scanf("%d%d%s", &n, &k, str + 1);
	K = min(k, 20);
	vector<bool> st(1 << K, 0);
	for (int i = 1, state = 0, num = 0; i <= n - K + 1; i ++ )
	{
		if (num >= k - K)
		{
			state = 0;
			for (int j = 0; j < K; j ++ ) state = state * 2 + (str[i + j] != '1');
			st[state] = 1;
		}
		num = (str[i] == '1' ? num + 1 : 0);
	}
	for (int i = 0; i < 1 << K; i ++ )
		if (!st[i])
		{
			puts("YES");
			for (int j = 1; j <= k - K; j ++ ) cout << '0';
			for (int j = K - 1; ~j; j -- ) cout << (i >> j & 1) ? '0' : '1';
			puts(""); return;
		}
	puts("NO");
}

int main()
{
	int t; cin >> t;
	while (t -- ) solve();
	return 0;
}