n,x = map(int, input().split()) M = 10**5+6 use = list(range(1,n+1)) use_lst = [0]*M v = 0 for i in range(1,n+1): v ^= i use_lst[i] = 1 free = list(range(n+1,M)) nn = M-n-1 cnt = 0 from random import randrange while v != x: idx = randrange(0,n) y = use[idx] v ^= y if 0 < v^x < M and use_lst[v^x]==0: use[idx] = v^x break jdx = randrange(0,nn) w = free[jdx] v ^= w use_lst[y] = 0 use_lst[w] = 1 use[idx],free[jdx] = w,y for i in use: print(i)