Problem A
Alchemy 101
As a student at Hogwarts School of Witchcraft and Wizardry,
Harry must learn Alchemy — the study of magical
properties of elements and transmutation of substances. In
today’s Alchemy lab session, Harry is experimenting with
transmuting substances. In the magical world, there are
infinite number of substances, numbered by positive integers.
When combining two substances
Let’s take a recap of how the bitwise xor operator works.
The bitwise xor is a binary operation that takes two bit
sequences of equal length and performs the logical exclusive or
operation on each pair of corresponding bits. The result in
each position is
0 |
1 |
0 |
1 |
(decimal |
|||
XOR |
0 |
0 |
1 |
1 |
(decimal |
||
0 |
1 |
1 |
0 |
(decimal |
Thus, we can write
-
, -
.
Harry wants to create the substance
Input
The first line of the input contains a single integer
Output
For each test case, print two lines:
-
The first line contains
— the largest number of substances Harry can use. -
The second line contains
integers, separated by spaces — the substances that Harry uses.
If there are more than one optimal answers, you must print
the one with smallest lexicographical
order. A list of substances
-
, -
.
Explanation of the sample input
-
, -
, -
.
Sample Input 1 | Sample Output 1 |
---|---|
3 1 4 5 |
1 1 4 1 2 3 4 4 1 2 3 5 |