#include #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, X; cin >> N >> X; vector p(7); rep(i, 7) p[i] = i + 1; set h1, h2, h3, h4; h1.insert(X); do { set s2 { p[0], X ^ p[0] }; set s3 { p[0], p[1], X ^ p[0] ^ p[1] }; set s4 { p[0], p[1], p[2], X ^ p[0] ^ p[1] ^ p[2] }; if (!s2.count(0) && *s2.rbegin() <= 100005 && s2.size() == 2) h2 = s2; if (!s3.count(0) && *s3.rbegin() <= 100005 && s3.size() == 3) h3 = s3; if (!s4.count(0) && *s4.rbegin() <= 100005 && s4.size() == 4) h4 = s4; } while (next_permutation(p.begin(), p.end())); set ans; if (N % 4 == 1) { ans = h1; } else if (N % 4 == 2) { ans = h2; } else if (N % 4 == 3) { ans = h3; } else { ans = h4; } for (int i = 8; i <= 100005 && ans.size() < N; i += 2) { if (!ans.count(i) && !ans.count(i ^ 1)) { ans.insert(i); ans.insert(i ^ 1); } } for (int x : ans) cout << x << '\n'; }