Bootstrap

Candies

C. Candies

Problem

This problem is about candy. Initially, you only have 1 1 1 candy, and you want to have exactly n n n candies.

You can use the two following spells in any order at most 40 40 40 times in total.

  • Assume you have x x x candies now. If you use the first spell, then x x x candies become 2 x − 1 2x-1 2x1 candies.
  • Assume you have x x x candies now. If you use the second spell, then x x x candies become 2 x + 1 2x+1 2x+1 candies.

Construct a sequence of spells, such that after using them in order, you will have exactly n n n candies, or determine it’s impossible.

Input

Each test contains multiple test cases. The first line contains a single integer t t t ( 1 ≤ t ≤ 1 0 4 1 \le t \le 10^4 1t104) — the number of test cases. Their description follows.

Each test case contains one line with a single integer n n n ( 2 ≤ n ≤ 1 0 9 2 \le n \le 10^9 2n109) — the required final number of candies.

Output

For each test case, output the following.

If it’s possible to eventually have n n n candies within 40 40 40 spells, in the first line print an integer m m m ( 1 ≤ m ≤ 40 1 \le m \le 40 1m40), representing the total number of spells you use.

In the second print m m m integers a 1 , a 2 , … , a m a_{1}, a_{2}, \ldots, a_{m} a1,a2,,am ( a i a_{i} ai is 1 1 1 or 2 2 2) separated by spaces, where a i = 1 a_{i} = 1 ai=1 means that you use the first spell in the i i i-th step, while a i = 2 a_{i} = 2 ai=2 means that you use the second spell in the i i i-th step.

Note that you do not have to minimize m m m, and if there are multiple solutions, you may output any one of them.

If it’s impossible, output − 1 -1 1 in one line.

Example

Input
4
2
3
7
17
Output
-1
1
2 
2
2 2 
4
2 1 1 1 

Note

For n = 3 n=3 n=3, you can just use the second spell once, and then have 2 ⋅ 1 + 1 = 3 2 \cdot 1 + 1 = 3 21+1=3 candies.

For n = 7 n=7 n=7, you can use the second spell twice. After the first step, you will have 3 3 3 candies. And after the second step, you will have 2 ⋅ 3 + 1 = 7 2 \cdot 3 + 1 = 7 23+1=7 candies.

Code

// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//堆/优先队列
// #include <queue>//队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

void solve()
{
    ll n;
    cin>>n;

    vector<ll> a;
    if(n%2==0)
    {
        cout<<-1<<endl;
        return;
    }

    while(n>1)
    {
        if(((n-1)/2)&1)
        {
            a.push_back(2);
            n=(n-1)/2;
        }
        else if(((n+1)/2)&1)
        {
            a.push_back(1);
            n=(n+1)/2;
        }
    }

    cout<<a.size()<<endl;
    reverse(a.begin(),a.end());
    for(auto &t:a)
        cout<<t<<" ";
    cout<<endl;
}

int main()
{
    ll t;
    cin>>t;
    while(t--) solve();
    
    return 0;
}

;