409249: GYM103469 A AND
Description
You had an array $$$a$$$. After that, you calculated bitwise ANDs of all subarrays of the original array. Formally, you calculated all numbers of the form $$$a_i~\texttt{AND}~a_{i + 1}~\texttt{AND}~\ldots~\texttt{AND}~a_j$$$ for $$$1 \le i \le j \le \mathrm{length}(a)$$$.
You remember the resulting set of all these numbers: a number lies in this set if and only if it can be represented as bitwise AND of at least one subarray. Sadly, you forgot the original array.
Find any array $$$a$$$ which would produce the given set of ANDs on subarrays, or determine that there is no such array.
InputThe first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$), the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$), the size of the given set.
The second line of each test case contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$0 \le b_i \le 2^{20} - 1$$$), the elements of the set. It is guaranteed that all elements are distinct.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.
OutputFor each test case, if there is no such array, output $$$-1$$$.
Otherwise, on the first line, output the size of the original array $$$k$$$ ($$$1 \le k \le 5n$$$).
On the next line, output $$$k$$$ integers $$$a_1, a_2, \ldots, a_k$$$ ($$$0 \le a_i \le 2^{20} - 1$$$), the elements of the array.
If there are several possible answers, print any one of them.
It can be shown that, if there is at least one array, then there is an array which satisfies these conditions.
ExampleInput3 1 5 3 0 1 2 2 1 2Output
3 5 5 5 3 1 0 2 -1Note
Note that the elements of the array that you output don't have to be distinct.