#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=3e5+10;
int f[maxn],k;
vector<int>ans;
signed main()
{
	f[1]=2;
	for(int i=2;i<=60;i++)	f[i]=2*f[i-1]+2;
	int t;
	cin>>t;
	while(t--){
		ans.clear();
		int flag=1;
		cin>>k;
		while(k){
			for(int i=60;i>=1;i--)
				if(f[i]<=k){
					k-=f[i];
					ans.push_back(1);
					for(int j=2;j<=i;j++) ans.push_back(0);
					break;
				}
			if(k%2==1){
                flag=0;
                break;
            }
		}
		if(ans.size()>2000)	flag=0;
		if(flag==0)	cout<<-1;
		else{
			cout<<ans.size()<<endl;
			for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
		}
		cout<<endl;
	}
	return 0;
}
