#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; } set res; auto add = [&](int l, int r) -> void { for (int i = l; i < r; ++i) { res.insert(i); } }; if (n % 4 == 0) { if (x < 4) { if (n == 4) { res.insert(16 | x); res.insert(20); res.insert(24); res.insert(28); } else { add(1, n + 4); res.erase(4 | x); int y = x < 3 ? x + 1 : 1; res.erase(y); res.erase(4 | y); } } else { add(1, 4); int m = n / 4 - 1; for (int i = 4; m; i += 4) { if (i <= x and x < i + 4) continue; add(i, i + 4); --m; } res.insert(x); } } else if (n % 4 == 1) { int m = n / 4; for (int i = 4; m; i += 4) { if (i <= x and x < i + 4) continue; add(i, i + 4); --m; } res.insert(x); } else if (n % 4 == 2) { assert(false); for (int i = x / 4 * 4; i < x / 4 * 4 + 4; ++i) if (i != x) { res.insert(i); } add(1, 4); int m = n / 4; for (int i = 4; m; i += 4) { if (i <= x and x < i + 4) continue; add(i, i + 4); --m; } } else { if (x < 4) { res.insert(4 | x); int y = x < 3 ? x + 1 : 1; res.insert(y); res.insert(4 | y); } else { for (int i = x / 4 * 4; i < x / 4 * 4 + 4; ++i) if (i != x) { res.insert(i); } } int m = n / 4; for (int i = 8; m; i += 4) { if (i <= x and x < i + 4) continue; add(i, i + 4); --m; } } for (int e : res) { cout << e << '\n'; } }