9082: Beautiful Sequence

内存限制:256 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:5 通过:4

题目描述

链接:https://ac.nowcoder.com/acm/contest/57361/C
来源:牛客网
Students from Antarctic Penguin Language School are studying sequence.

We call a sequence A=(A1,A2,…,An)A=(A_1, A_2, \dots, A_n)A=(A1,A2,,An) of length nnn beautiful when all the following conditions are true:
  •  A1≤A2≤⋯≤AnA_1 \le A_2 \le \dots \le A_nA1A2An
  •  For each AiA_iAi (1≤i≤n1\le i\le n1in), 0≤Ai<2300\le A_i<2^{30}0Ai<230.
  •  For each 1≤i<n1\le i<n1i<n, Ai⊕Ai+1=BiA_i\oplus A_{i+1}=B_iAiAi+1=Bi, where BBB is a given sequence, and ⊕\oplus represents bitwise XOR.
You need to find the kkk-th smallest lexicographically legal beautiful sequence AAA.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases TTT. The description of the test cases follows.
The first line contains two integers nnn, kkk (1≤n≤1061\le n\le 10^61n106, 1≤k≤2301\le k\le 2^{30}1k230).
The second line contains n−1n-1n1 integers B1,B2,…,Bn−1B_1, B_2, \dots, B_{n-1}B1,B2,,Bn1 (0≤Bi<2300\le B_i < 2^{30}0Bi<230).
It is guaranteed that the sum of nnn over all test cases does not exceed 10610^6106.

输出格式

For each test case, output your operations in the following format.
If the number of beautiful sequences is less than kkk, output one line containing an integer −1-11.
Otherwise, output one line containing nnn integers A1,A2,…,AnA_1, A_2, \dots, A_nA1,A2,,An separated by spaces --- the kkk-th smallest lexicographically legal beautiful sequence.

输入样例 复制

3
3 3
1 2
5 1
1 2 1 2
2 1
0

输出样例 复制

8 9 11
-1
0 0