Johnny is playing with a large binary number, . The number is so large that it needs to be compressed into an array of integers, , where the values in even indices () represent some number of consecutive bits and the values in odd indices () represent some number of consecutive bits in alternating substrings of .
For example, suppose we have array . represents , represents , represents , represents , and represents . The number of consecutive binary characters in the substring of corresponds to integer , as shown in this diagram:
When we assemble the sequential alternating sequences of 's and 's, we get .
We define setCount() to be the number of 's in a binary number, . Johnny wants to find a binary number, , that is the smallest binary number where setCount() = setCount(). He then wants to compress into an array of integers, (in the same way that integer array contains the compressed form of binary string ).
Johnny isn't sure how to solve the problem. Given array , find integer array and print its length on a new line. Then print the elements of array as a single line of space-separated integers.
The first line contains a single positive integer, , denoting the number of test cases. Each of the subsequent lines describes a test case over lines:
The first line contains a single positive integer, , denoting the length of array .
The second line contains positive space-separated integers describing the respective elements in integer array (i.e., ).
For a score, .
For a score, .
For each test case, print the following lines:
Print the length of integer array (the array representing the compressed form of binary integer ) on a new line.
Print each element of as a single line of space-separated integers.
It is guaranteed that a solution exists.
Sample Input 0
154 1 3 2 4
Sample Output 0
74 1 3 1 1 1 3
, which expands to . We then find setCount() . The smallest binary number which also has eleven 's is . This can be reduced to the integer array . This is demonstrated by the following figure:
Having found , we print its length () as our first line of output, followed by the space-separated elements in as our second line of output.