#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
	int k;
	cin >> k;
	string ans;
	int cnt = 0;
	for (int i = 0; i <= k; i++) {
		string s;
		int x = i, y = k - i;
		while (x || y) {
			if (x > y) {
				for (int j = 0; j < x / (y + 1); j++)
					s += '1';
				x %= (y + 1);
			}
			else if (x < y) {
				for (int j = 0; j < y / (x + 1); j++)
					s += '0';
			
				y %= (x + 1);
			}
			else {
				s.clear();
				break;
			}
		}
		if (!s.empty()) {
			cnt++;
			if (ans.empty() || (int)ans.size() > (int)s.size()) ans = s;
		}
	}
	cout << cnt << '\n';
	for (auto i : ans)
		cout << i << ' ';
	cout << '\n';
}
int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int T;
	cin >> T;
	while (T--) solve();
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |