#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll exp(ll a,ll b)
{
	if(b==0)
	 return 1;
	if(b%2==0)
	 return exp(a*a,b/2);
	return a*exp(a*a,(b-1)/2);
}
void solve()
{
	ll num;
	cin>>num;
	if(num%2){
		cout<<"-1\n";
		return ;
	}
	vector<int>arr;
	ll sum=0;
	while(num)
	{
		int i=1;
		int ans=1;
		while(1)
		{
			ll var=exp(2,i+1)-2;
			if(var>=num)
			 break;
			ans=i;
			i++;
		}
		arr.push_back(ans);
		sum+=ans;
		num-=(exp(2,ans+1)-2);
	}
	cout<<sum<<"\n";
	for(int var : arr){
		for(int j=0; j<var; j++){
			if(j==0)
			 cout<<"1 ";
			else
			 cout<<"0 ";
		}
	}
	cout<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T;
	cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}