#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, x; cin >> n >> x; if (n == 2) { if (x == 1) { cout << 2 << '\n'; cout << 3 << '\n'; } else { cout << 1 << '\n'; cout << (x ^ 1) << '\n'; } return 0; } V<> res; auto add = [&](int l, int r) -> void { for (int i = l; i < r; ++i) { res.push_back(i); } }; assert(n % 4 <= 1); if (n % 4 == 0) { if (x < 4) { assert(false); res.push_back(16 | x); res.push_back(20); res.push_back(24); res.push_back(28); } else { add(1, 4); int m = n / 4 - 1; for (int i = 4; m; i += 4, --m) { if (i <= x and x < i + 4) continue; add(i, i + 4); } res.push_back(x); } } else if (n % 4 == 1) { int m = n / 4; for (int i = 4; m; i += 4, --m) { if (i <= x and x < i + 4) continue; add(i, i + 4); } res.push_back(x); } else if (n % 4 == 2) { for (int i = x / 4 * 4; i < x / 4 * 4 + 4; ++i) if (i != x) { res.push_back(i); } add(1, 4); int m = n / 4; for (int i = 4; m; i += 4, --m) { if (i <= x and x < i + 4) continue; add(i, i + 4); } } else { for (int i = x / 4 * 4; i < x / 4 * 4 + 4; ++i) if (i != x) { res.push_back(i); } int m = n / 4; for (int i = 4; m; i += 4, --m) { if (i <= x and x < i + 4) continue; add(i, i + 4); } } for (int e : res) { cout << e << '\n'; } }