#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def fill(A, N): N -= len(A) B = A[:] for i in range(2, 10 ** 5 + 4, 2): if not N: break if (i in A) or (i + 1 in A): continue N -= 2 B.append(i) B.append(i + 1) return B def solve(N, X): if X == 1: if N % 4 == 0: return fill([1, 3, 5, 6], N) elif N % 4 == 1: return fill([1], N) elif N % 4 == 2: return fill([2, 3], N) else: return fill([3, 5, 7], N) if N % 4 == 0: return fill([1, X], N) elif N % 4 == 1: return fill([X], N) elif N % 4 == 2: return fill([1, X ^ 1], N) else: return fill([X ^ 1], N) N, X = map(int, read().split()) A = solve(N, X) print('\n'.join(map(str, A)))