408851: GYM103351 A Modulo Sequence

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

Description

A. Modulo Sequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given a single positive integer $$$M$$$. Construct an array of positive integers $$$a_1, \ldots, a_n$$$ such that:

  • $$$1 \le a_i \le M$$$ for all $$$1 \le i \le n$$$;
  • $$$a_i \bmod a_{i-1} = a_{i-2}$$$ for all $$$3 \le i \le n$$$;
  • The size of the array $$$n$$$ is largest possible.
Input

The first line of the input contains a single integer $$$T$$$ — the number of test cases ($$$1 \le T \le 10$$$).

Each test case is given as a line containing a single integer $$$M$$$ ($$$1 \le M \le 10^9$$$).

Output

Output exactly two lines for each test case. The first line should contain a single integer $$$n$$$ — the size of your array.

The second line should contain $$$n$$$ space-separated integers $$$a_1, \ldots, a_n$$$ — the array itself.

ExampleInput
2
2
3
Output
3
1 2 1
4
1 2 3 2

加入题单

算法标签: