from collections import deque n,x = map(int, input().split()) M = 10**5+6 use = [0]*M v = 0 for i in range(1,n+1): use[i] = 1 v ^= i free = deque(range(n+1,M)) cnt = 0 from random import randrange while v != x: while True: i = randrange(1,M) if use[i]==1: break use[i] = 0 free.append(i) v ^= i if 0 < v^x < M and use[v^x] == 0: use[v^x] = 1 break w = free.popleft() use[w] = 1 v ^= w for i in range(M): if use[i]: print(i)