Construct a sequence a = {a_1,\ a_2,\ ...,\ a_{2^{M + 1}}} of length 2^{M + 1} that satisfies the following conditions, if such a sequence exists.
 - Each integer between 0 and 2^M - 1 (inclusive) occurs twice in a.
 - For any i and j (i < j) such that a_i = a_j, the formula a_i \ xor \ a_{i + 1} \ xor \ ... \ xor \ a_j = K holds.
What is xor (bitwise exclusive or)?
The xor of integers c_1, c_2, ..., c_n is defined as follows:
 - When c_1 \ xor \ c_2 \ xor \ ... \ xor \ c_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among c_1, c_2, ...c_m whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even.
For example, 3 \ xor \ 5 = 6. (If we write it in base two: 011 xor 101 = 110.)

-----Constraints-----
 - All values in input are integers.
 - 0 \leq M \leq 17
 - 0 \leq K \leq 10^9

-----Input-----
Input is given from Standard Input in the following format:
M K

-----Output-----
If there is no sequence a that satisfies the condition, print -1.
If there exists such a sequence a, print the elements of one such sequence a with spaces in between.
If there are multiple sequences that satisfies the condition, any of them will be accepted.

-----Sample Input-----
1 0

-----Sample Output-----
0 0 1 1

For this case, there are multiple sequences that satisfy the condition.
For example, when a = {0, 0, 1, 1}, there are two pairs (i,\ j)\ (i < j) such that a_i = a_j: (1, 2) and (3, 4). Since a_1 \ xor \ a_2 = 0 and a_3 \ xor \ a_4 = 0, this sequence a satisfies the condition.

Difficulty: interview

Starter code:

Solutions:
#!/usr/bin/env python3
def main():
    M, K = map(int, input().split())
    if K == 0:
        print(*[i//2 for i in range(2**(M+1))])
    else:
        if K >= 2**M or M <= 1:
            print(-1)
        else:
            nums = []
            for i in range(2**M):
                if i != K:
                    nums.append(i)
            a = [nums[0], K, nums[0]]
            b = []
            for i in range(1,2**M-1):
                b.append(nums[i])
            b.append(K)
            for i in range(1,2**M-1):
                b.append(nums[2**M-1-i])
            print(*a,*b)
def __starting_point():
    main()
__starting_point()

def main():
    M, K = list(map(int, input().split()))
    if M == 1:
        if K == 0:
            print('0 0 1 1')
        else:
            print('-1')
        return
    if K >= 2 ** M:
        print((-1))
        return
    r = []
    for i in range(2 ** M):
        if i != K:
            r.append(i)
    r.append(K)
    for i in reversed(list(range(2 ** M))):
        if i != K:
            r.append(i)
    r.append(K)
    print((' '.join(str(i) for i in r)))
main()


m, k = list(map(int, input().split()))

if m == 0:
    if k == 0:
        print('0 0')
    else:
        print('-1')
elif m == 1:
    if k == 0:
        print('0 0 1 1')
    elif k >= 1:
        print('-1')
else:
    if k < 2 ** m:
        l = list(range(2 ** m))
        l.pop(k)
        ans = l + [k] + l[::-1] + [k]
        print((' '.join(map(str, ans))))
    else:
        print((-1))



m, k = list(map(int, input().split()))
if m == 1 and k == 1:
    print((-1))
elif m == 1 and k == 0:
    print("0 0 1 1")
elif 2**m > k:
    ans = str(k)
    y = []
    for i in range(2**m):
        if i == k:
            continue
        y.append(str(i))
    ans =  ' '.join(reversed(y)) + ' ' + ans + ' ' + ' '.join(y) + ' ' +ans
    print(ans)
else:
    print((-1))


M,K = map(int, input().split())

if K >= pow(2, M):
    print(-1)
elif K == 0:
    ans = []
    for i in range(pow(2, M)):
        ans.append(i)
        ans.append(i)
    print(*ans)
else:
    num = 0
    L = []
    for i in range(pow(2, M)):
        if i == K:
            continue
        num ^= i
        L.append(i)
    if num == K:
        L2 = list(reversed(L))
        ans = L + [K] + L2 + [K]
        print(*ans)
    else:
        print(-1)

m, k = map(int, input().split())
if not (0<=k<2**m):
  print(-1)
  return
if m == 1:
  if k == 0:
    print(0, 0, 1, 1)
  else:
    print(-1)
else:
  L = []
  for i in range(2**m):
    if i != k:
      L.append(i)
  L.append(k)
  for i in range(2**m-1, -1, -1):
    if i != k:
      L.append(i)
  L.append(k)
  print(*L)

# 解説AC
M,K = map(int, input().split())

if M == 1:
    if K == 0:
        print("0 0 1 1")
    else:
        print(-1)
else:
    if (1 << M) <= K:
        print(-1)
    else:
        ans = [n for n in range(1 << M) if n != K]
        ans.append(K)
        ans += [n for n in range((1 << M) - 1, -1, -1) if n != K]
        ans.append(K)
        print(*ans)

# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

M, K = lr()
if K >= 2 ** M:
    print((-1)); return
if M == 1:
    if K == 0:
        print("0 0 1 1")
    else:
        print((-1))
    return
A = [x for x in range(2 ** M) if x != K]
answer = A + [K] + A[::-1] + [K]
print((*answer))
# 22


m,k=map(int,input().split())
x=[*range(1<<m)]
print(*x+x[::-1]if k<1else x[:k:-1]+x[k-1::-1]+[k]+x[:k]+x[k+1:]+[k]if(k<2**m)&(m>1)else[-1])

m,k = map(int,input().split())
if m == 0:
    if k == 0:
        print(0,0)
    else:
        print(-1)
    return
if m == 1:
    if k== 0:
        print(0,0,1,1)
    else:
        print(-1)
    return
if k < 2**m:
    l = [i for i in range(2**m) if i != k ]
    l = l + [k] + l[::-1] + [k]
    print(*l)
else:
    print(-1)

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

M, K = lr()

if 2**M <= K or (M == 1 and K == 1):
    print((-1)); return

if K == 0:
    answer = [x//2 for x in range(2**(M+1))]

else:
    answer = []
    A = [x for x in range(2**M) if x != K]
    answer.extend(A)
    if K != 0:
        answer.append(K)
    answer.extend(A[::-1])
    if K != 0:
        answer.append(K)

print((*answer))


m,k=map(int,input().split())
x=[*range(1<<m)]
print(*k<1and x+x[::-1]or k<1<<m>2and[k]+x[k+1:]+x[:k]+[k]+x[k-1::-1]+x[:k:-1]or[-1])

import sys
input = sys.stdin.readline

M,K = list(map(int,input().split()))

if M==1:
    if K==0:
        print((0,0,1,1))
    else:
        print((-1))
else:
    if K >= (1<<M):
        print((-1))
    else:
        a = list(range(1<<M))
        a.remove(K)
        ans = a + [K] + a[::-1] + [K]
        print((" ".join(map(str,ans))))


m, k = list(map(int, input().split()))

if m == 0:
    if k == 0:
        ans = [0, 0]
    else:
        ans = []

elif m == 1:
    if k == 0:
        ans = [0, 0, 1, 1]
    else:
        ans = []

elif k < 2 ** m:
    li = list(range(2 ** m))
    li.remove(k)
    ans = li + [k] + li[::-1] + [k]

else:
    ans = []

if ans:
    print((*ans))
else:
    print((-1))


m, k = map(int, input().split())
if m == 0:
    if k == 0:
        print(0, 0)
    else:
        print(-1)
elif m == 1:
    if k == 0:
        print(0, 0, 1, 1)
    else:
        print(-1)
else:
    if k>=2**m:
        print(-1)
    else:
        L = [i for i in range(2 ** m) if i != k]
        ans = L + [k] + L[::-1] + [k]
        print(*ans, sep=' ')
    

from itertools import chain
m,k=map(int,input().split())
if 0<k<2**m and m>=2:
    print(*[str(i) for i in chain(range(0,k),range(k+1,2**m),[k],range(2**m-1,k,-1),range(k-1,-1,-1),[k])])
elif k==0:
    print(*[str(i) for i in chain(range(0,2**m),range(2**m-1,-1,-1))])
else:
    print(-1)

m, k = map(int, input().split())
if k >= 2**m:
  print(-1)
elif m == 0:
  print(0, 0)
elif m == 1:
  if k == 0:
    print(0, 0, 1, 1)
  else:
    print(-1)
else:
  for i in range(2**m):
    if i == k:
      continue
    print(i, end=" ")
  print(k, end=" ")
  for i in range(2**m-1, -1, -1):
    if i == k:
      continue
    print(i, end=" ")
  print(k)

M, K = map(int, input().split())

#K と K の間で K を作れれば、数列は存在する。  
#絶対に作れないパターン
if K >= 2 ** M:
  print("-1")
  return
if M == 0:
  print(0, 0)
  return
elif M == 1:
  if K == 0:
    print(0, 0, 1, 1)
  else:
    print(-1)
  return
#K と K の間で K を作れれば、数列は存在する。  
  
now = 0  
for i in range(2 ** M):
  if i != K:
    now = now^i
  #print(now)
#print(now)

print(K, end = " ")
for i in range(2 ** M):
  if i != K:
    print(i, end = " ")
print(K, end = " ")
for i in range(2 ** M):
  if (2 ** M - 1 - i) != K:
    print(2 ** M - 1 - i, end = " ")
  
  
  

  
  

from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    m,k=MI()
    if (m,k)==(1,1) or k>=2**m:ans=[-1]
    elif k==0:
        ans=list(range(1<<m))
        ans+=ans[::-1]
    else:
        ans=[]
        for i in range(1<<m):
            if i==k:continue
            ans.append(i)
        rev=ans[::-1]
        ans.append(k)
        ans+=rev
        ans.append(k)
    print(*ans)

main()


M,K = list(map(int, input().split()))

if 2 ** M <= K:
  print((-1))
  return
  
if M == 0:
  print((0,0))
elif M == 1 and K == 0:
  print((0,0,1,1))
elif M == 1 and K >= 1:
  print((-1))
else:
  A = list(range(2**M))
  B = A[:K] + A[K+1:]
  C = list(map(str, B + [K] + B[::-1] + [K]))
  print((" ".join(C)))
  


import sys
from itertools import permutations

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    M, K = list(map(int, readline().split()))

    if M == 0:
        if K == 0:
            print((0, 0))
            return
        else:
            print((-1))
            return
    elif M == 1:
        if K == 0:
            print((0, 0, 1, 1))
            return
        else:
            print((-1))
            return
    elif K >= pow(2, M):
        print((-1))
        return

    vec = [i for i in range(pow(2, M)) if i != K]
    ans = vec + [K] + vec[::-1] + [K]

    print((' '.join(map(str, ans))))
    return


def __starting_point():
    main()

__starting_point()

def main():
    M, K = list(map(int, input().split(' ')))
    if K >= 2 ** M:
        print((-1))
        return
    if M == 0:
        print('0 0')
        return
    if M == 1:
        if K == 0:
            print('0 0 1 1')
        else:
            print((-1))
        return
    # M >= 2 and K < 2 ** M
    arr = list(map(str, [i for i in range(2 ** M) if i != K]))
    rev_arr = arr.copy()
    rev_arr.reverse()
    ans = arr + [str(K)] + rev_arr + [str(K)]
    print((' '.join(ans)))


def __starting_point():
    main()

__starting_point()

m,k=map(int,input().split())
if 2**m<=k:
    print(-1)
elif m==1:
    if k==0:
        print(0, 0, 1, 1)
    else:
        print(-1)
else:
    a=[i for i in range(2**m) if i!=k]
    ans=[k]+a+[k]+a[::-1]
    print(*ans)  

def solve():
    M, K = map(int, input().split())
    if K>=1<<M:
        return [-1]
    if M==1:
        if K==0:
            return [1,0,0,1]
        return [-1]
    ans = [K]
    for i in range(1<<M):
        if i!=K:
            ans.append(i)
    ans.append(K)
    for i in range((1<<M)-1,-1,-1):
        if i!=K:
            ans.append(i)
    return ans
print(*solve())

m,k=map(int,input().split())
x=[*range(1<<m)]
print(*(x+x[::-1])*(k<1)or([k]+x[k+1:]+x[:k]+[k]+x[k-1::-1]+x[:k:-1])*(m>1<=k<1<<m)or[-1])

M, K = map(int, input().split())

if K==0:
    l = []
    for i in range(2**M):
        l += [i, i]
    print(*l)
elif M==0 or M==1:
    print(-1)
elif 1<=K<2**M:
    l = []    
    for i in range(2**M):
        if i!=K:
            l += [i]
    l += [K]
    for i in range(2**M)[::-1]:
        if i!=K:
            l += [i]
    l += [K]
    print(*l)
else:
    print(-1)

m,k=map(int,input().split())
x=list(range(2**m))
print(*x[::-1]+x if k==0 else x[:k:-1]+x[k-1::-1]+[k]+x[:k]+x[k+1:]+[k] if k<2**m and m>1 else[-1])

m,k=map(int,input().split())
if k>2**m-1:
  print(-1)
elif k==0:
  ans=[i for i in range(2**m)]
  ans=ans+ans[::-1]
  print(*ans)
else:
  if m==1:
    print(-1)
  else:
    ans=[]
    for i in range(2**m):
      if i==k:
        continue
      ans.append(i)
    ans=[k]+ans+[k]+ans[::-1]
    print(*ans)

M, K = map(int, input().split())

ans = [-1]
if M == 1:
  if K == 0:
    ans = [0, 0, 1, 1]
else:
  if K < 2**M:
    b = [i for i in range(2**M) if i != K]
    ans = b + [K] + b[::-1] + [K]

print(*ans)

import sys
input = sys.stdin.readline
from functools import reduce
from operator import xor


def read():
    M, K = list(map(int, input().strip().split()))
    return M, K


def solve(M, K):
    seq = [str(0) for i in range(2**(M+1))]
    if K == 0:
        for i in range(2**M):
            seq[2*i] = str(i)
            seq[2*i+1] = str(i)
    else:
        if K >= 2**M:
            return -1
        # (A) K ... 0 K 0 rev(...), xor(...) == K の形を作れればOK
        S = [a for a in range(2**M) if a not in (0, K)]
        if len(S) == 0 or reduce(xor, S) != K:
            return -1
            
        j = 0
        for i in range(2**M-2):
            j += 1
            if j == K:
                j += 1
            seq[i+1] = str(j)
            seq[2**(M+1) - i - 1] = str(j)
        seq[0] = str(K)
        seq[2**M] = str(K)
        
    return " ".join(seq)


def __starting_point():
    inputs = read()
    print((solve(*inputs)))

__starting_point()

M, K = (int(i) for i in input().split())

if M == 1:
    if K == 0:
        print("0 0 1 1")
    else:
        print("-1")
else:
    N = 2**M
    if K >= N:
        print("-1")
    elif K == 0:
        l = list(range(N))
        ll = l + l[::-1]
        ll = [str(a) for a in ll]
        print(" ".join(ll))
    else:
        l = list(range(N))
        l = l[:K] + l[K+1:]
        ll = [0, K] + l + [K] + l[::-1][:-1]
        ll = [str(a) for a in ll]
        print(" ".join(ll))   

m,k=list(map(int,input().split()))
if 2**m<=k:print((-1));return
if m==1:
  if k==0:print((0,0,1,1))
  else:print((-1))
  return
a=[i for i in range(2**m) if i!=k]
ans=[k]+a+[k]+a[::-1]
print((*ans))


m,k=list(map(int,input().split()))
if 2**m<=k or m*k==1:
    print((-1))
elif m==1 and k==0:
    print("0 0 1 1")
else:
    ans=[-1 for i in range(2**(m+1))]
    sta=2**m-1
    cnt=0
    for i in range(1,2**m):
        if cnt==k:
            cnt+=1
        ans[sta+i]=cnt
        ans[sta-i]=cnt
        cnt+=1
    ans[sta]=k
    ans[-1]=k
    
    print((" ".join([str(i) for i in ans])))
    


m,k=map(int,input().split())
if k>=2**m or m==k==1:
	print(-1)
elif m==1:
	print("1 1 0 0")
else:
	l=list(range(k))+list(range(k+1,2**m))
	print(*(l+[k]+l[::-1]+[k]))

m,k=map(int,input().split())
x=[*range(1<<m)]
print(*x[::-1]+x if k<1else x[:k:-1]+x[k-1::-1]+[k]+x[:k]+x[k+1:]+[k]if(k<2**m)&(m>1)else[-1])

M,K = map(int,input().split())

num = 2**(M+1)

if K >= num//2 or (M==1 and K==1):
    ans = [-1]
elif M==1 and K==0:
    ans = [0,0,1,1]
else:
    ans = [0]*num
    for i in range(2**M):
        if i==K: continue
        ans[i-(i>K)] = i
        ans[num-2-i+(i>K)] = i
    ans[num//2-1] = K
    ans[-1] = K
    
print(*ans)

M, K = list(map(int, input().split()))

if K >= 2 ** M:
    print((-1))
elif (M, K) == (1, 0):
    print((*(0, 0, 1, 1)))
elif (M, K) == (1, 1):
    print((-1))
else:
    # 3, 5 -> [7 6 4 3 2 1 0 5 0 1 2 3 4 6 7 5]
    ans = [0] * (2 ** (M + 1))
    ans[2 ** M - 1] = ans[-1] = K

    num = 0
    for i in range(2 ** M - 1):
        if num == K:
            num += 1
        ans[2 ** M - i - 2] = ans[2 ** M + i] = num
        num += 1
    print((*ans))


from itertools import chain
m,k=map(int,input().split())
if k==0:
    print(" ".join([str(i) for i in chain(range(0,2**m),range(2**m-1,-1,-1))]))
elif 0<k<2**m:
    s=0
    for i in range(0,2**m):
        if i!=k:
            s^=i
    if s==k:
        print(" ".join([str(i) for i in chain(range(0,k),range(k+1,2**m),[k],range(2**m-1,k,-1),range(k-1,-1,-1),[k])]))
    else:
        print(-1)
else:
    print(-1)

def power(n, m):
    ret = 1
    for i in range(m):
        ret *= n
    return ret

M, K = map(int, input().split())
if K >= power(2, M):
    print(-1)
else:
    if M == 0:
        print(0, 0)
    elif M == 1:
        if K == 1:
            print(-1)
        else:
            print(0, 0, 1, 1)
    else:
        ans = []
        N = power(2, M)
        if K % 2 == 1:
            ans.append(K)
            ans.append(K - 1)
            for i in range(0, N):
                if i == K or i == K - 1:
                    continue
                ans.append(i)
            ans.append(K)
            for i in range(N - 1, -1, -1):
                if i == K or i == K - 1:
                    continue
                ans.append(i)
            ans.append(K - 1)
        else:
            ans.append(K)
            ans.append(K + 1)
            for i in range(0, N):
                if i == K or i == K + 1:
                    continue
                ans.append(i)
            ans.append(K)
            for i in range(N - 1, -1, -1):
                if i == K or i == K + 1:
                    continue
                ans.append(i)
            ans.append(K + 1)
        print(" ".join(map(str, ans)))

M, K = map(int, input().split())

if M == 0:
  if K == 0:
    print(0, 0)
  else:
    print(-1)
elif M == 1:
  if K == 0:
    print(0, 0, 1, 1)
  else:
    print(-1)
elif K < (1 << M):
  for i in range(1 << M):
    if i != K:
      print(i, end=" ")
  print(K, end=" ")
  for i in range((1 << M) - 1, -1, -1):
    if i != K:
      print(i, end=" ")
  print(K)
else:
  print(-1)

m, k = map(int, input().split())
if 2**m <= k:
    print(-1)
    return
elif m == 0 and k == 0:
    print("0 0")
    return
elif m == 1 and k == 1:
    print(-1)
    return
elif m == 1 and k == 0:
    print("1 1 0 0")
    return
l = [i for i in range(2**m) if i != k]
rev_l = sorted(l, reverse=True)
ans = l + [k] + rev_l + [k]
print(" ".join(map(str, ans)))

import sys
M, K = map(int,input().split())
if M == 0:
    if K == 0:
        print(*[0, 0])
    else:
        print(-1)
    return

if M == 1:
    if K == 0:
        print(*[0, 1, 1, 0])
    else:
        print(-1)
    return

N = 2 ** M

if K >= N:
    print(-1)
    return

ans = []

for i in range(N):
    if i != K:
        ans.append(i)

ans.append(K)

for i in range(N-1,-1,-1):
    if i != K:
        ans.append(i)

ans.append(K)

print(*ans)

m, k = list(map(int, input().split()))

if m == 0:
    if k == 0:
        print('0 0')
    else:
        print('-1')
elif m == 1:
    if k == 0:
        print('0 0 1 1')
    elif k >= 1:
        print('-1')
else:
    if k < 2 ** m:
        l = []
        for i in range(2 ** m):
            if i != k:
                l.append(i)

        ans = l + [k] + l[::-1] + [k]

        ans2 = ''
        for a in ans:
            ans2 += str(a) + ' '
        print((ans2[:-1]))
    else:
        print((-1))


m,k=map(int,input().split())
if k>2**m-1:
    print(-1)
elif m==1 and k==1:
    print(-1)
else:
    a,b=0,0
    i=0
    while k>0:
        if k%2:
            a+=2**i
        k//=2
        i+=1
    #print(a)
    if a==0:
        ans=[]
        for i in range(2**m):
            ans.append(i)
            ans.append(i)
    else:
        ans=[0]*2**(m+1)
        ans[2**m-1]=b
        ans[-1]=a
        ans[2**m]=a
        ans[0]=b
        s={a,b}
        idx=0
        #print(ans)
        for i in range(2**m):
            if i not in s:
                ans[idx+1]=i
                ans[-2-idx]=i
                idx+=1
    print(*ans)

m,k=list(map(int,input().split()))
if k>=2**m:
    print((-1))
elif m==1:
    if k==0: print((0,0,1,1))
    else: print((-1))
else:
    tmp=k
    for i in range(1,2**m):
        tmp^=i
    ans=[i for i in range(2**m) if i!=k]+[k]+[i for i in range(2**m-1,-1,-1) if i!=k]+[k]
    print((*ans))


MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    m,k = map(int,input().split())
    if k >= pow(2,m):
        print(-1)
        return
    if m == 1:
        if k == 1:
            print(-1)
        else:
            print('{0} {0} {1} {1}'.format(0,1))
        return
    
    ans = [k]
    ans2 = [k]
    lim = pow(2,m)
    for i in range(lim):
        if i != k:
            ans.append(i)
        if lim - i - 1 != k:
            ans2.append(lim - i - 1)
    ans += ans2
    print(*ans)  

def __starting_point():
    main()  
__starting_point()

m, k = list(map(int, input().split()))
if m == 1:
    if k == 0:
        print((0, 0, 1, 1))
    else:
        print((-1))
else:
    s = 2 ** m
    if k >= s:
        print((-1))
    else:
        ans = [k]
        for i in range(s):
            if i != k:
                ans.append(i)
        ans.append(k)
        for i in range(s - 1, -1, -1):
            if i != k:
                ans.append(i)
        print((*ans))


import sys

input = sys.stdin.readline


# Editorial AC
def main():
    M, K = list(map(int, input().split()))

    if K >= 2 ** M:
        print((-1))
        return

    if M == 1:
        if K == 0:
            print((0, 0, 1, 1))
        else:
            print((-1))
        return

    A = list(range(2 ** M))
    B = list(reversed(list(range(2 ** M))))
    A.remove(K)
    B.remove(K)

    ans = A + [K] + B + [K]
    print((" ".join(map(str, ans))))


def __starting_point():
    main()

__starting_point()

M, K = list(map(int, input().split()))

if M <= 1:
    if K > 0:
        print(-1)
        return
    else:
        if M == 1:
            print(" ".join(["0", "0" , "1", "1"]))
            return
        else:
            print("0 0")
            return
elif K >= 2 ** M:
        print(-1)
        return
ans = [str(K)]
exclude_k = [str(i) for i in range(2 ** M) if i != K]
ans.extend(exclude_k)
ans.append(str(K))
ans.extend(exclude_k[::-1])
print(" ".join(ans))

m,k=map(int,input().split())
x=[*range(1<<m)]
print(*(([-1],[k]+x[k+1:]+x[:k]+[k]+x[k-1::-1]+x[:k:-1])[k<1<<m>2],x+x[::-1])[k<1])

m,k=map(int,input().split())
if m==1:
  if k!=0:
    print(-1)
  else:
    print(0,0,1,1)
  return
elif 2**m<=k:
  print(-1)
  return
b=[]
for i in range(2**m):
  if i!=k:
    b.append(i)
c=b[::-1]
d=b+[k]+c+[k]
print(*d)

M, K = map(int, input().split())
def binary_digits(n):
  cnt = 0
  while n != 0:
    cnt += 1
    n //= 2
  return cnt
if binary_digits(K) > M:
  print(-1)
else:
  if M == 1:
    if K == 1:
      print(-1)
    elif K == 0:
      print(0, 0, 1, 1)
  else:
    b = 2**(M+1)
    if K == 0:
      for i in range(b):
        if i != b - 1:
          print(i // 2, end = ' ')
        else:
          print(i // 2)
    else:
      A = [0 for i in range(b)]
      A[1], A[b//2+1] = K, K
      p = 1
      for i in range(1, b//2):
        if i != K:
          A[b//2-p+1], A[b//2+p+1] = i, i
          p += 1
      for i in range(b):
        if i != b - 1:
          print(A[i], end = ' ')
        else:
          print(A[i])

import itertools
M,K=map(int,input().split())

if M==1 and K==1:
  print(-1)
elif K==0:
  ans_list=[]
  for i in range(2**M):
    ans_list.extend([i,i])
  print(*ans_list)
elif K<2**M:
  ans_list=[]
  for i in range(K+1):
    ans_list.append(i)
  for i in reversed(range(K)):
    ans_list.append(i)
  for i in reversed(range(K,2**M)):
    ans_list.append(i)
  for i in range(K+1,2**M):
    ans_list.append(i)
  print(*ans_list)
else:
  print(-1)

m, k = list(map(int, input().split()))

if m == 1:
    if k == 0:
        ans = [0, 0, 1, 1]
    else:
        ans = []

elif k < 2 ** m:
    li = list(range(2 ** m))
    li.remove(k)
    ans = li + [k] + li[::-1] + [k]

else:
    ans = []

if ans:
    print((*ans))
else:
    print((-1))


m,k=map(int,input().split())
x=[*range(1<<m)]
print(*x+x[::-1]if k<1else[k]+x[k+1:]+x[:k]+[k]+x[k-1::-1]+x[:k:-1]if(k<2**m)&(m>1)else[-1])

m, k = [int(x) for x in input().split()]
if m == 1:
    if k == 0:
        print(0, 0, 1, 1)
    else:
        print(-1)
else:
    if k < 1 << m:
        a = [str(i) for i in range(1 << m) if i != k]
        print(' '.join(a), k, ' '.join(reversed(a)), k)
    else:
        print(-1)

m, k = map(int, input().split())
if m == 0:
    if k == 0:
        print(0, 0)
    else:
        print(-1)
elif m == 1:
    if k == 0:
        print(0, 1, 1, 0)
    else:
        print(-1)
else:
    a = 2 ** m - 1
    if k > a:
        print(-1)
    else:
        for num in range(a + 1):
            if num == k:
                continue
            print(num, end = " ")
        print(k, end = " ")
        for num in range(a, -1, -1):
            if num == k:
                continue
            print(num, end = " ")
        print(k)

m, k = map(int, input().split())
if k >= 2**m:
  print(-1)
  return
if m == 0:
  print(0, 0)
elif m == 1:
  if k == 0:
    print(0, 1, 1, 0)
  else:
    print(-1)
else:
  b = [i for i in range(2**m) if i != k]
  c = b[::-1]
  A = b + [k] + c + [k]
  print(*A)

def xor_matching(M, K):
    # 0と1はコーナーケースっぽい
    if M == 0:
        return [0, 0] if K == 0 else [-1]
    if M == 1:
        return [0, 1, 1, 0] if K == 0 else [-1]

    if K >= (1 << M):
        return [-1]

    values = list(range(1 << M))
    Amax = values[-1]
    res = []
    res.append(K)
    for v in values:
        if v == K:
            continue
        res.append(v)
    res.append(K)
    for v in values[::-1]:
        if v == K:
            continue
        res.append(v)
    return res


def __starting_point():
    M, K = list(map(int, input().split()))
    ans = xor_matching(M, K)
    print((*ans))

__starting_point()

M,K=map(int,input().split())
if M==0 and K==0:
  ans=[0,0]
elif M==1:
  if K==0:
    ans=[0,0,1,1]
  else:
    ans=[-1]
elif K>=2**M:
  ans=[-1]
else:
  ans=[]
  for i in range(2**M):
    if i!=K:
      ans.append(i)
  ans.append(K)
  for j in range(2**M-1,-1,-1):
    if j!=K:
      ans.append(j)
  ans.append(K)
for i in ans:
  print(i,end=' ')

M, K = list(map(int, input().split()))

if M < 2:
    if K != 0:
        print((-1))
    else:
        anss = []
        for A in range(2**M):
            anss += [A, A]
        print((' '.join(map(str, anss))))
else:
    if K > 2**M - 1:
        print((-1))
    else:
        anss = []
        for A in range(2**M):
            if A == K: continue
            anss.append(A)
        anss = anss + [K] + anss[::-1] + [K]
        print((' '.join(map(str, anss))))


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    m,k = map(int, input().split())
    if m == 0:
        if k == 0:
            print(0, 0)
        else:
            print(-1)
    elif m == 1:
        if k == 0:
            print(0,0,1,1)
        else:
            print(-1)
    else:
        if k >= 2**m:
            print(-1)
        else:
            res = []
            for i in range(2**m):
                if i != 0 and i != k:
                    res.append(i)
            if k == 0:
                res = res + [0] + res[::-1] + [0]
            else:
                res = res + [0, k] + res[::-1] + [k, 0]
            print(*res)

def __starting_point():
    main()
__starting_point()

m, k = map(int, input().split())
ret = []
if k >= 2 ** m or (m == 1 and k == 1):
    ret.append(-1)
elif m == 1:
    ret = [0, 0, 1, 1]
else:
    ret.append(k)
    for i in range(2 ** m):
        if i != k:
            ret.append(i)
    ret.append(k)
    for i in range(2 ** m - 1, -1, -1):
        if i != k:
            ret.append(i)
print(' '.join(map(str, ret)))

M, K = map(int,input().split())

if K >= 2**M:
    print(-1)
    return
elif M == 0:
    print("0 0")
elif M == 1:
    if K == 0:
        print("0 0 1 1")
    else:
        print(-1)
else:
    A = [i for i in range(2**M) if i != K]
    B = A[::-1]

    for a in A: print(a, end = " ")
    print(K, end=" ")
    for b in B: print(b, end=" ")
    print(K)


m,k=map(int,input().split())
x=list(range(2**m))
print(*x[::-1]+x if k<1 else x[:k:-1]+x[k-1::-1]+[k]+x[:k]+x[k+1:]+[k]if(k<2**m)&(m>1)else[-1])

M, K = map(int, input().split())

if K>=(2**M):
    print(-1)
elif M==0:
    if K==0:
        print(0, 0)
    else:
        print(-1)
elif M==1:
    if K==0:
        print(0, 0, 1, 1)
    else:
        print(-1)
else:
    b = [str(i) for i in range(2**M) if not i==K]
    c = [str(i) for i in range(2**M-1, -1, -1) if not i==K]
    ans = b+[str(K)]+c+[str(K)]
    print(' '.join(ans))

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
M,K = map(int,input().split())
if M == 1:
    if K == 0:
        ans = [0,0,1,1]
        print(*ans)
    else:
        print(-1)
else:
    if K > 2**M - 1 :
        print(-1)
    else:
        if K == 0:
            ans = []
            for i in range(2**M):
                ans.append(i)
                ans.append(i)
            print(*ans)
        else:
            ans = deque([K])
            for i in range(2**M):
                if i == K:
                    continue
                ans.append(i)
                ans.appendleft(i)
            ans.append(K)
            print(*ans)

#!python3

def LI():
    return list(map(int, input().split()))

# input
M, K = LI()


def solve():
    n = 2 ** M
    l = [i for i in range(n) if i != K]
    ret = l + [K] + l[::-1] + [K]
    return ret


def main():
    if K >= 2 ** M:
        ans = [-1]
    elif M == 1:
        if K == 0:
            ans = [0, 0, 1, 1]
        else:
            ans = [-1]
    else:
        ans = solve()

    print((*ans))


def __starting_point():
    main()

__starting_point()

m,k=map(int,input().split())
x=[*range(1<<m)]
print(*(x+x[::-1])*(k<1)or([k]+x[k+1:]+x[:k]+[k]+x[k-1::-1]+x[:k:-1])*(k<1<<m>2)or[-1])

import sys
M,K=[int(i) for i in input().split()]
#M,K=1,0
if K>=2**M:
    print(-1)
    return
    
if M==1:
    if K==0:
        print(*[0,0,1,1])
        return
    else:
        print(-1)
        return
L=[]
l=[int(i) for i in range(2**M) if i !=K]
L.extend(l)
L.append(K)
L.extend(l[::-1])
L.append(K)

print(*L)

m,k = map(int,input().split())
if m*k == 1:
  print(-1)
  return
  
if k == 0:
  ans = []
  for i in range(2**m):
    ans.append(i)
    ans.append(i)
  print(*ans)
  return
  
if 2**m <= k:
  print(-1)
else:
  ans = [k]
  chk = list(range(2**m))
  chk.remove(k)
  ans = ans+chk+[k]+chk[::-1]
  print(' '.join(map(str,ans)))

M, K = map(int, input().split())

if M == 0:
	if K == 0:
		print(0, 0)
	else:
		print(-1)
	return

if M == 1:
	if K == 0:
		print(0, 0, 1, 1)
	else:
		print(-1)
	return

N = 2 ** M
if N <= K:
	print(-1)
	return

ans = []
ans.append(K)

for i in range(N):
	if i == K:
		continue
	ans.append(i)

ans.append(K)

for i in range(N-1, -1, -1):
	if i == K:
		continue
	ans.append(i)

for i in ans:
	print(i, end=' ')

m,k=map(int,input().split())
if 1<<m<=k:print(-1);return()
if m==1:print(*[-1]if k else [0,0,1,1]);return
l=[i for i in range(1<<m)if i!=k]
print(*(l+[k]+l[::-1]+[k]))

# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-
# # 問題：https://atcoder.jp/contests/abc126/tasks/abc126_f
# # 解説動画を見ながら実装

import sys

m, k = map(int, input().strip().split())
max_num = 2**m
if k >= max_num:
    print(-1)
    return

if m == 0:
    print('0 0')
    return

if m == 1:
    if k == 0:
        print('0 0 1 1')
    else:
        print('-1')
    return

res = []
for i in range(max_num):
    if i == k:
        continue
    res.append(i)
res.append(k)
for i in range(max_num):
    j = max_num - i - 1
    if j == k:
        continue
    res.append(j)
res.append(k)
for i in range(2**(m+1)):
    print(res[i], end=' ')


M, K = list(map(int, input().split()))

if K >= 2**M:
    print((-1))
elif M == 0:
    if K == 0:
        print((0,0))
    else:
        print((-1))
elif M == 1:
    if K >= 1:
        print((-1))
    else:
        print((0,0,1,1))
else:
    li = [i for i in range(2**M) if i != K]
    ans = li + [K] + list(reversed(li)) + [K]
    print((*ans))


m,k = map(int, input().split())
if k >= 2 ** m:
  print(-1)
  return
if m == 1:
  if k == 0:
    print(0,0,1,1)
  if k == 1:
    print(-1)
  return
base = [i for i in range(2**m) if i != k]
ans = base + [k] + base[::-1] + [k]
print(*ans)

def main():
    M, K = list(map(int, input().split()))
    if M == 1:
        if K == 0:
            print('0 0 1 1')
            return
        if K == 1:
            print('-1')
            return
    if (2**M) - 1 < K:
        print('-1')
        return
    l = [i for i in range(K)] + [i for i in range(K+1, (2**M))] + [K] + [i for i in reversed(list(range(K+1, (2**M))))] + [i for i in reversed(list(range(K)))] + [K]
    print((' '.join(str(i) for i in l)))
main()


# F - XOR Matching
from collections import deque

m, k = map(int, input().split())

# k>=2^mの時は成立しない
if k>=pow(2,m):
    print(-1)

# m=0の時
elif m==0:
    print(0, 0)

# m=1の時
elif m==1:
    if k==0:
        print(0, 0, 1, 1)
    else:
        print(-1)

# m>=2の時
else:
    ans = deque()
    ans.append(k)
    for i in range(pow(2,m)):
        if i!=k:
            ans.append(i)
            ans.appendleft(i)
    ans.append(k)
    print(' '.join(map(str, ans)))

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def debug(L, k):
    n = len(L)
    used = set()
    for i in range(n):
        if L[i] in used:
            continue
        used.add(L[i])
        t = L[i]
        for j in range(i + 1, n):
            t ^= L[j]
            if L[i] == L[j]:
                break
        if t != k:
            return False
    return True


def resolve():
    m, k = list(map(int, input().split()))

    MAX = pow(2, m)
    if MAX <= k or (m == 1 and k == 1):
        print((-1))
        return

    if m == 1 and k == 0:
        print("0 0 1 1")
        return

    res = []
    for i in range(MAX):
        if i == k:
            continue
        res.append(i)
    res.append(k)
    for i in reversed(list(range(MAX))):
        if i == k:
            continue
        res.append(i)
    res.append(k)
    print((*res))
    # print(debug(res, k))


def __starting_point():
    resolve()

__starting_point()

m, k = list(map(int, input().split()))
if m==1 and k==0:
    print((0,0,1,1))
    return
if m==k==1:
    print((-1))
    return

if 2**m<=k:
    print((-1))
    return
ans = [k]
for i in range(2**m):
    if i != k:
        ans.append(i)
ans.append(k)
for i in reversed(list(range(2**m))):
    if i != k:
        ans.append(i)
print((*ans))


M,K= list(map(int,input().split()))

if K >= 2**M:
    print((-1))
    return

if M == 0:
    print("0 0")
    return

if M == 1:
    if K == 0:
        print("0 0 1 1")
    if K == 1:
        print((-1))
    return

left = [i for i in range(2**M) if not i == K]

ans = left + [K] + left[::-1] + [K]

print((*ans))




M,K = map(int, input().split())
if M==1:
  if K==0:
    print(0,0,1,1)
  else:
    print(-1)
elif K>=2**M:
  print(-1)
else:
  ls = list(range(2**M))
  ls.remove(K)
  ans = [K]+ls+[K]+ls[::-1]
  print(' '.join(map(str,ans)))

def test(m):
    t = [i for i in range(2**m)]
    for i in range(2**m):
        t.append(i)
    t.sort()
    st = set()
    bt = set()
    from itertools import permutations
    for v in permutations(t):
        taget = v[0]
        x = 0
        idx = 1
        while idx < len(v) and v[idx] != taget:
            x = x ^ v[idx]
            idx += 1
        if x in st or x in bt:
            continue
        f = True
        for i in range(1, len(v)):
            g = False
            y = 0
            idx = i+1
            while idx < len(v):
                if v[i] == v[idx]:
                    g = True
                    break
                y = y ^ v[idx]
                idx += 1
            if g:
                if y != x:
                    f = False
                    break
        if f:
            st.add(x)
            print(x, v)

def main():
    m, k = map(int, input().split())
#    test(m)
    x = 0
    for i in range(2**m):
        if i == k:
            continue
        x ^= i
    if k == 0:
        for i in range(2**m):
            print(i, i, end=" ")
    elif x == k:
        for i in range(2**m):
            if i == k:
                continue
            print(i, end=" ")
        print(k, end=" ")
        for i in reversed(range(2**m)):
            if i == k:
                continue
            print(i, end=" ")
        print(k)
    else:
        print(-1)

def __starting_point():
    main()
__starting_point()

m, k = list(map(int, input().split()))

if k >= 2**m:
    print((-1))
    return

if m == 0:
    print((0, 0))
    return
if m == 1:
    if k == 0:
        print((0, 0, 1, 1))
        return
    else:
        print((-1))
        return

A = [k]
for i in range(2**m):
    if i == k:
        continue
    A.append(i)
A.append(k)
for i in range(2**m - 1, -1, -1):
    if i == k:
        continue
    A.append(i)

print((*A))


import math
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

def int_input():
    return list(map(int, input().split()))

m, k = int_input()
if k == 0:
    l = []
    for i in range(2 ** m):
        l.append(i)
    m = l[:]
    m.reverse()
    ans = m + l
    print((*ans))
else:
    v = 0
    l = []
    for i in range(2 ** m):
        if i != k:
            l.append(i)
            v ^= i
    m = l[:]
    m.reverse()
    ans = m + [k] + l + [k]
    if v == k: print((*ans))
    else: print((-1))



m, k = map(int, input().split())

if m == 0:
    if k == 0:
        print(0, 0)
    else:
        print(-1)

elif m == 1:
    if k == 0:
        print(0, 0, 1, 1)
    else:
        print(-1)

else:
    if k >= 2 ** m:
        print(-1)
        return

    res = []
    for i in range(2 ** m):
        if i == k:
            continue
        res.append(i)

    ans = [k] + res + [k] + res[::-1]
    print(*ans)

def main():
  M,K=map(int,input().split())
  if K == 0:
    ans = []
    for i in range(2**M):
        ans.extend([i, i])
    print(*ans)
    return 0
  if 2**M <= K:
    print(-1)
    return 0
  if M==1:
    if K==1:
      print(-1)
      return 0

  ans=[str(x) for x in range(2**M) if x!=K]
  ans_b=[str(x) for x in range(2**M-1,-1,-1) if x!=K]
  print(str(K)+" "+" ".join(ans)+" "+str(K)+" "+" ".join(ans_b))
main()

m,k=map(int,input().split())
x=[*range(1<<m)]
print(*(x+x[::-1])*(k<1)or([k]+x[k+1:]+x[:k]+[k]+x[k-1::-1]+x[:k:-1])*(k<2**m)*(m>1)or[-1])

import bisect
import sys


input = sys.stdin.readline
sys.setrecursionlimit(100000)


class v:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)


def read_values():
    return list(map(int, input().split()))


def read_list():
    return list(read_values())


def main():
    M, K = read_values()
    if K >= 2 ** M:
        print((-1))
        return

    if M == 1:
        print(("0 0 1 1" if K == 0 else -1))
        return

    X = [str(i) for i in range(2 ** M) if i != K]
    res = X + [str(K)] + X[::-1] + [str(K)]
    print((" ".join(res)))


def __starting_point():
    main()

__starting_point()

M, K = list(map(int, input().split()))

if K == 0:
    print((*(list(range(2 ** M)) + list(range(2 ** M - 1, -1, -1)))))
else:
    if M <= 1:
        print((-1))
    elif K.bit_length() > M:
        print((-1))
    else:
        index = 0
        used = [False] * (2 ** M)
        ans = []
        for _ in range(2 ** (M-2)):
            while index < 2 ** M and used[index]:
                index += 1
            A = index
            C = index ^ K
            used[index] = True
            used[index^K] = True
            while index < 2 ** M and used[index]:
                index += 1
            B = index
            D = index ^ K
            used[index] = True
            used[index^K] = True
            ans += [A, C, B, D, C, A, D, B]
        print((*ans))


M,K = map(int,input().split())

if M == 0:
    if K == 0:
        print(0,0)
    else:
        print(-1)
elif M == 1:
    if K == 0:
        print(0,0,1,1)
    else:
        print(-1)
else:
    if K == 0:
        A = [i//2 for i in range(2**(M+1))]
        print(*A)
    elif 0 < K < 2**M:
        A = []
        for i in range(K):
            A.append(i)
        for i in range(2**M-K-1):
            A.append(2**M-i-1)
        A.append(0)
        for i in range(2**M-K):
            A.append(K+i)
        for i in range(K-1):
            A.append(K-i-1)
        A.append(K)
        print(*A)
    else:
        print(-1)

import sys
input = sys.stdin.buffer.readline

def main():
    M,K = map(int,input().split())
    if M == 0:
        if K == 0:
            print(0,0)
        else:
            print(-1)
    elif M == 1:
        if K == 0:
            print(0,0,1,1)
        else:
            print(-1)
    else:
        if 2**M <= K:
            print(-1)
        else:
            use = [i for i in range(2**M)]
            use.pop(K)
            _use = list(reversed(use))
            ans = use+[K]+_use+[K]
            print(*ans)

def __starting_point():
    main()
__starting_point()

m, k = map(int, input().split())
if pow(2, m) <= k:
    print(-1)
elif not m == 1:
    ans = [k] * pow(2, m + 1)
    i = 0
    for j in range(pow(2, m) - 1):
        if i == k:
            i += 1
        ans[j] = i
        ans[pow(2, m + 1) - 2 - j] = i
        i += 1
    print(*ans)
else:
    if k == 0:
        print(0, 0, 1, 1)
    else:
        print(-1)

m,k = map(int,input().split())
if m == 1:
    if k == 0:
        print(0,0,1,1)
    else:
        print(-1)
elif 2**m <= k:
    print(-1)
else:
    remain = set(range(2**m))
    use = set()
    count = 0
    while k:
        if k & 1:
            remain.remove(2**count)
            use.add(2**count)
        k >>= 1
        count += 1
    ans = []
    remain = list(remain)
    use = list(use)
    for i in remain:
        ans.append(str(i))
    for i in use:
        ans.append(str(i))
    for i in remain[::-1]:
        ans.append(str(i))
    for i in use[::-1]:
        ans.append(str(i))
    print(" ".join(ans))

m, k = map(int, input().split())
v = []
if k == 0:
  for i in range(0, 2**m):
    v.append(i)
    v.append(i)
elif k < 2**m and m > 1:
  for i in range(0, 2**m):
    if i != k:
      v.append(i)
  v.append(k)
  for i in range(2**m-1, -1, -1):
    if i != k:
      v.append(i)
  v.append(k)
if len(v) == 0:
  print(-1)
else:
  for i in range(0, len(v)):
    print(v[i])
    if i == len(v)-1:
      print("\n")
    else:
      print(" ")

m,k=map(int,input().split());x=list(range(2**m));print(*x[::-1]+x if k<1 else x[:k:-1]+x[k-1::-1]+[k]+x[:k]+x[k+1:]+[k]if(k<2**m)&(m>1)else[-1])

#!/usr/bin/env python3
import sys


def solve(M: int, K: int):
    if K >= (1 << M):
        print(-1)
        return
    if M == 1:
        if K == 0:
            print(0, 0, 1, 1)
        else:
            print(-1)
        return
    for i in range(1 << M):
        if i != K:
            print(i, end=" ")
    print(K, end=" ")
    for i in reversed(range(1 << M)):
        if i != K:
            print(i, end=" ")
    print(K)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(M, K)


def __starting_point():
    main()

__starting_point()

# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-
# # 問題：https://atcoder.jp/contests/abc126/tasks/abc126_f
# # 解説動画を見ながら実装

import sys

m, k = map(int, input().strip().split())
max_num = 2**m
if k >= max_num:
    print(-1)
    return

# if m == 0:
#     print(0)
#     return

if m == 1:
    if k == 0:
        print('0 0 1 1')
    else:
        print('-1')
    return

res = []
for i in range(max_num):
    if i == k:
        continue
    res.append(i)
res.append(k)
for i in range(max_num):
    j = max_num - i - 1
    if j == k:
        continue
    res.append(j)
res.append(k)
for i in range(2**(m+1)):
    print(res[i], end=' ')


m,k=map(int,input().split())
if k<=2**m-1 and m>1:
    lists=[]
    for i in range(2**m-1,-1,-1):
        if i!=k:
            lists.append(i)
    lists.append(k)
    for i in range(2**m):
        if i!=k:
            lists.append(i)
    lists.append(k)
    print(*lists)
elif k<=2**m-1 and m==0:
    print(*[0,0])
    
elif k<=2**m-1 and m==1:
    if k==0:
        print(*[0,0,1,1])
    elif k==1:
        print(-1)

else:
    print(-1)

m,k = map(int, input().split())

if k >= 2**m:
    print(-1)

elif m == 1:
    if k == 0:
        print(0, 0, 1, 1)

    else:
        print(-1)

else:
    a = [i for i in range(2**m) if i != k]
    ans = [k] + a + [k] + a[::-1]
    print(*ans)