#include <iostream>
#include <vector>

using namespace std;

vector<bool> binary(int x) {

	vector <bool> a;

	while (x >= 1) {
		a.insert(a.begin(), x % 2);
		x /= 2;
	}
	return a;


	/*
	if (x >= 1) {
		return binary(x/2).insert(binary(x / 2).begin(), x % 2);
	}
	return binary(x);
	*/
}

void filter(vector<bool>* x, vector<bool>* y) {

	if (x->size() > y->size()) {
		for (unsigned int i = 0; i < x->size() - y->size(); i++) {
			y->push_back(0);
		}
	}
	else if (x->size() < y->size()) {
		for (unsigned int i = 0; i < y->size() - x->size(); i++) {
			x->push_back(0);
		}
	}
}

vector<bool> operation(vector<bool> x, vector<bool> y, bool isAnd) {
	vector<bool> newVec;

	if (isAnd) {
		for (int i = 0; i < x.size(); i++) {
			newVec.insert(newVec.begin(), x[i] && y[i]);
		}
	}
	else {
		for (int i = 0; i < x.size(); i++) {
			newVec.insert(newVec.begin(), x[i] || y[i]);
		}
	}

	return newVec;
}

bool check(vector<bool> x, vector<bool> y) {

	for (int i = 0; i < x.size(); i++) {
		if (x[i] != y[i]) {
			return false;
		}
	}

	return true;

}


void possible(vector<vector<bool>> x, vector<bool> k) {

	for (unsigned int i = x.size(); i > 1; i--) {

		filter(x[i], x[i - 1]);

		operation(x[i], x[i - 1], true);
		operation(x[i], x[i - 1], false);


	}

}

int main() {

	int T, N, K, a;

	vector<vector<bool>> s;

	cin >> T;

	for (; T > 0; T--) {
		cin >> N;
		cin >> K;
		vector<bool> k = binary(K);

		for (; N > 0; N--) {
			cin >> a;

			s.insert(s.begin(), binary(a));

		}
		cout << s.size();
		for (unsigned int i = 0; i < s.size(); i++) {
			for (unsigned int j = 0; j < s[i].size(); j++) {
				cout << s[i][j];
			}

			cout << endl;
		}
		s.clear();
	}

	return 0;

}