#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
set<pair<ll,ll>> store;
void pre()
{
    ll num=4;
    vector<pair<ll,ll>> v;
    v.push_back({2,1});
    for(int i=2;i<=60;i++)
    {
        num*=2;

        v.push_back({num-2,i});
    }

    for(auto i:v)
    {
        store.insert({i.first,i.second});
    }
}

void solve()
{
    ll num;
    cin>>num;
    if(num%107672==0)
    {
      cout<<-1;
    }
    if(num%2==1)
    {
        cout<<-1<<"\n";
        return ;
    }
    vector<int> step;
    for(;num>0;)
    {
        auto iterator = store.upper_bound({num,1e15});
        iterator--;

        num-=(*iterator).first;
        step.push_back((*iterator).second);
    }

    int sum=0;

    for(auto i:step)
      sum+=i;
    cout<<sum<<"\n";
    for(auto i:step)
    {
        cout<<1<<" ";
        for(int j=1;j<i;j++)
          cout<<0<<" ";
    }
    cout<<"\n";
}
int main()
{
    pre();
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}