406958: GYM102625 D Best Wishes !!

Memory Limit:100 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Best Wishes !!time limit per test1.5 secondsmemory limit per test100 megabytesinputstandard inputoutputstandard output

Suddenly, Raju Chacha came to know that the old director DCP, dearly known as Pani, was being transferred back to ISM, within a few days. He became afraid, and decided to levy some charges for using the parent portal to access MIS, to earn a huge revenue till he is present.

Within some time, he came up with an idea and sent the following mail to the student community -

" It has came to my notice that since few days, some mischievous students are accessing the parent portal many times, by means of some script. This is a big no no. Due to this, the network traffic on the parent portal has been increasing exponentially, day by day.

So, from today, a new policy will be implemented to charge the students for using the parent portal, as follows:

(i) Rs. 1 will be charged for using the portal on the first day (today).

(ii) For access to the parent portal on subsequent days, the student will be charged either double or triple of the previous charges, or the charges will be incremented by 1.

i.e. If the student was charged Rs. $$$d_i$$$ on the $$$i^{th}$$$ day, then he would be charged either 2*$$$d_i$$$ , 3*$$$d_i$$$ or 1+$$$d_i$$$ on the $$$(i+1)^{th}$$$ day.

Hope you are enjoying your vacations.

Best Wishes !!"

His main aim was to earn exactly Rs. $$$D$$$ from a single student on a single day. But he wants to do it, in the minimum number of days possible, assuming that there is one student who uses the parent portal daily.

Unfortunately, Raju Chacha doesn't know programming. He needs your help to develop a program which would take the amount $$$D$$$ as input and output the minimum number of days the portal must be accessed (say $$$m$$$) by a student, to earn that amount on a single day.

Along with this, it should also output a sequence of valid charges that should be imposed on each day, so that the charges on the $$$m^{th}$$$ day is Rs. $$$D$$$.

If there are multiple such sequences of length $$$m$$$, you may output any one of them.

Input

The first line of the input contains a single integer $$$T$$$ denoting the number of test cases. The description of $$$T$$$ test cases follows.

The first and only line of each test case contains a single integer $$$D$$$.

1 $$$\leq$$$ $$$T$$$ $$$\leq$$$ $$$10^5$$$

1 $$$\leq$$$ $$$D$$$ $$$\leq$$$ $$$10^6$$$

Output

For each test case, print 2 lines -

The first line containing one integer $$$m$$$ — the minimum number of days, the parent portal must be accessed by a single student, such that he needs to pay Rs. $$$D$$$ on the $$$m^{th}$$$ day.

The second line should contain a sequence of $$$m$$$, integers, representing the charges to be paid on each day.

ExamplesInput
3
1
5
96234
Output
1
1 
4
1 3 4 5 
15
1 3 9 10 11 33 99 297 891 2673 8019 16038 16039 48117 96234 
Input
1
1000000
Output
20
1 3 9 27 54 108 216 217 651 1953 3906 7812 15624 15625 31250 62500 125000 250000 500000 1000000 
Note

In the first example, $$$D=1$$$ . Since, the initial charge for the $$$1^{st}$$$ day is Rs. 1 itself, so it requires only 1 day, to accomplish the goal.

In the second example, $$$D=5$$$ . Here, we triple the charges for the second day and then increment by 1, for 2 days to achieve the charges of Rs. 5.

Another possibility is to double the charges for 2 days and then increment by 1 on the $$${4^{th}}$$$ day. Hence "1 2 4 5" is also a valid output in this case.

加入题单

算法标签: