#include<bits/stdc++.h>
 
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e9
#define vi vector<ll>
// #define ll long long ll
 
typedef long long ll;
ll mod = 998244353;
 long long fast_exp(long long a, long long b)
{
    if(b <= 0)
       return 1;
    else
    {
       long long res = 1;
       res = fast_exp(a,b/2);
       res = (res*res)%mod;
       if(b%2 == 1)
          res = (res*a)%mod;
       return res;
 
    }
}

typedef long double ld;
const long long N = 2e5+10;
ll a[2000][2000];


 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("elimination_input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll t;
    cin >> t;
    ll f[62] = {};
    ll p[62] = {};
    p[0] = 1;
    for(ll i = 1; i<61; i++)
    {
        p[i] = 2 * (p[i-1]);
        //cout << "p[i]: "<< p[i] <<"  i:" << i << " \n";

    }
    cout << '\n';
    for(ll i = 0; i<60; i++)
    {
        f[i] = 2 * (p[i+1] - 1);
        //cout << "f[i]: "<< f[i] << "  i: "<< i << '\n';
    }


    while(t--)
    {
        ll k;
        cin >> k;
        ll ptr = 59;
        vector <ll> ans;
        ll sum = 0;
        //cout << "f[ptr]: "<< f[ptr] << '\n';
        while(ptr >= 0)
        {
            if(f[ptr] <= k)
            {
                k = k - f[ptr];
                ans.pb(ptr);
                sum += ptr + 1;
            }
            else
                ptr--;
        }
        reverse(ans.begin(),ans.end());
        // cout << "ans : ";
        // for(auto e: ans)
        //     cout << e << " ";
        // cout << '\n';
        if(k == 0)
        {
            cout << sum << '\n';

            for(auto e: ans)
            {
                cout << 1 << " ";
                for(ll j = 0; j<e; j++)
                    cout << 0 << " ";
            }

        }
        else
            cout << -1 ;
        cout << '\n';

    }
    
    // cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
    return 0;
    
}