CF2162C.Beautiful XOR

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Beautiful XOR

You are given two integers aa and bb. You are allowed to perform the following operation any number of times (including zero):

  • choose any integer xx such that 0xa0 \le x \le a (the current value of aa, not initial),
  • set a:=axa := a \oplus x. Here, \oplus represents the bitwise XOR operator.

After performing a sequence of operations, you want the value of aa to become exactly bb.

Find a sequence of at most 100100 operations (values of xx used in each operation) that transforms aa into bb, or report that it is impossible.

Note that you are not required to find the minimum number of operations, but any valid sequence of at most 100100 operations.

Input

The first line of input contains a single integer tt (1t10001 \le t \le 1000) — the number of test cases.

Each test case contains two integers aa and bb (1a,b1091 \le a, b \le 10^9).

Output

For each test case, if it is impossible to obtain bb from aa using the allowed operations, print a single line containing 1-1.

Otherwise, on the first line print a single integer kk (0k1000 \le k \le 100) — the number of operations. On the second line print kk integers (x1,x2,,xkx_1, x_2, \dots , x_k) — the chosen values of xx in the order you apply them.

If there are multiple valid sequences, you may print any one of them.

Note

For the first test case,

  • choose x=7x = 7, now aa becomes equal to 97=149 \oplus 7 = 14.
  • choose x=8x = 8, now aa becomes equal to 148=614 \oplus 8 = 6.

Thus, we can make a=ba = b.

For the fourth test case, choosing x=5x = 5 makes a=ba = b.

Samples

6
9 6
13 13
292 929
405 400
998 244
244 353
2
7 8
0
-1
1
5
2
25 779
-1

在线编程 IDE

建议全屏模式获得最佳体验