#GYM104679F. Lucky Seats

Lucky Seats

Description

The FIFA World Cup 2022 will take place in Qatar. The organizers plan to provide a prize to random attendees at the opening game. So they chose two integers $a$ and $b$. The integer $a$ represents bitwise $\textbf{OR}$ of a set of seat numbers and $b$ represents bitwise $\textbf{XOR}$ of the same set of seat numbers. The attendees assigned to those seats will receive the prizes. The organizers want to award prizes to as many people as possible. They therefore recruited you to identify the maximum possible number of attendees who are qualified for the award as well as their seat numbers. Each seat has a unique seat number, which is a non-negative integer.

See the notes if you forgot what bitwise $\textbf{OR}$ and $\textbf{XOR}$ means.

Each test consists of multiple test cases. The first line contains a single integer $T\space(1 \leq T \leq 100) $ — the number of test cases.

For each testcase, there will be two numbers representing $a$ and $b$ $(0 \leq a, b \leq 10^4)$.

For each testcase, if there is no solution, print $\textbf{-1}$.

Otherwise, print two lines.

  • First line will contain the maximum possible number of attendees who will get prize.
  • The next line will contain the seat numbers in increasing order separated by a single space. If there are multiple solutions for the given input, print any of them.

Input

Each test consists of multiple test cases. The first line contains a single integer $T\space(1 \leq T \leq 100) $ — the number of test cases.

For each testcase, there will be two numbers representing $a$ and $b$ $(0 \leq a, b \leq 10^4)$.

Output

For each testcase, if there is no solution, print $\textbf{-1}$.

Otherwise, print two lines.

  • First line will contain the maximum possible number of attendees who will get prize.
  • The next line will contain the seat numbers in increasing order separated by a single space. If there are multiple solutions for the given input, print any of them.
3
5 1
11 2
11 4
3
0 4 5
7
0 1 3 8 9 10 11
-1

Note

Consider the first sample test. One can verify that the bitwise OR of the numbers $[0,4,5]$ is $5$, and the bitwise XOR of the numbers $[0,4,5]$ is $1$. One can verify that there's no set of (distinct) numbers with a bigger size that satisfies these conditions.

Bitwise XOR: The bitwise XOR of non-negative integers $A$ and $B$, denoted $A\oplus B$, is defined as follows:

  • When $A\oplus B$ is written in base two, the $k$-th digit from the right $(k\geq 0)$ is $1$ if and only if exactly one of the digits in that place of $A$ and $B$ is $1$, and $0$ otherwise. For example, we have $3\oplus 5=6$ (in base two: $011\oplus 101=110$).

Bitwise OR: The bitwise OR of non-negative integers $A$ and $B$, denoted $A\mid B$, is defined as follows:

  • When $A\mid B$ is written in base two, the $k$-th digit from the right $(k\geq 0)$ is $1$ if and only if at least one of the digits in that place of $A$ and $B$ is $1$, and $0$ otherwise. For example, we have $3\mid 5=7$ (in base two: $011\mid 101 = 111$).