CF1934D1.XOR Break — Solo Version

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is the solo version of the problem. Note that the solution of this problem may or may not share ideas with the solution of the game version. You can solve and get points for both versions independently.

You can make hacks only if both versions of the problem are solved.

Given an integer variable xx with the initial value of nn . A single break operation consists of the following steps:

  • Choose a value yy such that 0<y<x0 \lt y \lt x and 0<(xy)<x0 \lt (x \oplus y) \lt x .
  • Update xx by either setting x=yx = y or setting x=xyx = x \oplus y .

Determine whether it is possible to transform xx into mm using a maximum of 6363 break operations. If it is, provide the sequence of operations required to achieve x=mx = m .You don't need to minimize the number of operations.

Here \oplus denotes the bitwise XOR operation.

输入格式

The first line contains one positive integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases.

Each test case consists of a single line containing two integers nn and mm ( 1m<n10181 \leq m \lt n \leq 10^{18} ) — the initial value of xx and the target value of xx .

输出格式

For each test case, output your answer in the following format.

If it is not possible to achieve mm in 6363 operations, print 1-1 .

Otherwise,

The first line should contain kk ( 1k631 \leq k \leq 63 ) — where kk is the number of operations required.

The next line should contain k+1k+1 integers — the sequence where variable xx changes after each break operation. The 11 -st and k+1k+1 -th integers should be nn and mm , respectively.

输入输出样例

  • 输入#1

    3
    7 3
    4 2
    481885160128643072 45035996273704960

    输出#1

    1
    7 3
    -1
    3
    481885160128643072 337769972052787200 49539595901075456 45035996273704960

说明/提示

In the first test case n=7n = 7 , for the first operation x=7x = 7 if we choose y=3y = 3 then (73)<7(7 \oplus 3) \lt 7 , hence we can update xx with 33 which is equal to mm .

In the second test case n=4n = 4 , for the first operation x=4x = 4 .

If we choose:

  • y=1y = 1 then (41)>4(4 \oplus 1) \gt 4
  • y=2y = 2 then (42)>4(4 \oplus 2) \gt 4
  • y=3y = 3 then (43)>4(4 \oplus 3) \gt 4

Hence we can't do the first operation and it is impossible to make x=2x = 2 .

首页