100 atcoder#ABC126F. [ABC126F] XOR Matching

[ABC126F] XOR Matching

Score : 600600 points

Problem Statement

Construct a sequence aa = {a1, a2, ..., a2M+1a_1,\ a_2,\ ...,\ a_{2^{M + 1}}} of length 2M+12^{M + 1} that satisfies the following conditions, if such a sequence exists.

  • Each integer between 00 and 2M12^M - 1 (inclusive) occurs twice in aa.
  • For any ii and jj (i<j)(i < j) such that ai=aja_i = a_j, the formula ai xor ai+1 xor ... xor aj=Ka_i \ xor \ a_{i + 1} \ xor \ ... \ xor \ a_j = K holds.
What is xor (bitwise exclusive or)?

The xor of integers c1,c2,...,cnc_1, c_2, ..., c_n is defined as follows:

  • When c1 xor c2 xor ... xor cnc_1 \ xor \ c_2 \ xor \ ... \ xor \ c_n is written in base two, the digit in the 2k2^k's place (k0k \geq 0) is 11 if the number of integers among c1,c2,...cmc_1, c_2, ...c_m whose binary representations have 11 in the 2k2^k's place is odd, and 00 if that count is even.

For example, 3 xor 5=63 \ xor \ 5 = 6. (If we write it in base two: 011 xorxor 101 == 110.)

Constraints

  • All values in input are integers.
  • 0M170 \leq M \leq 17
  • 0K1090 \leq K \leq 10^9

Input

Input is given from Standard Input in the following format:

MM KK

Output

If there is no sequence aa that satisfies the condition, print -1.

If there exists such a sequence aa, print the elements of one such sequence aa with spaces in between.

If there are multiple sequences that satisfies the condition, any of them will be accepted.

1 0
0 0 1 1

For this case, there are multiple sequences that satisfy the condition.

For example, when aa = {0,0,1,10, 0, 1, 1}, there are two pairs (i, j) (i<j)(i,\ j)\ (i < j) such that ai=aja_i = a_j: (1,2)(1, 2) and (3,4)(3, 4). Since a1 xor a2=0a_1 \ xor \ a_2 = 0 and a3 xor a4=0a_3 \ xor \ a_4 = 0, this sequence aa satisfies the condition.

1 1
-1

No sequence satisfies the condition.

5 58
-1

No sequence satisfies the condition.