#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0; i #define VLL vector #define VVI vector> #define VVLL vector> #define VC vector #define VS vector #define VVC vector> #define VB vector #define VVB vector> #define fore(i,a) for(auto &i:a) typedef pair P; template bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 1 << 30; const ll INFL = 1LL << 60; const ll mod = 1000000007; int main() { int n, x; cin >> n >> x; VI v(20, 0); int sum = 0; REP(i, 20) { if ((1 << i)&x) { v[i]++; sum++; } } if (n == 1) { cout << x << endl; return 0; } if (n == 2) { if (x == 1) { cout << 2 << endl; x ^= 2; cout << x << endl; } else { cout << 1 << endl; x ^= 1; cout << x << endl; } return 0; } int m = n; if (m % 2 == 0)m--; m -= 2; int a = 0; if (n % 4 == 1)m -= 2; FOR(i, 1, m + 1) { cout << i << endl; a ^= i; n--; } x ^= a; if (n == 2) { FOR(i, m + 1, 100005) { int j = x ^ i; if (m < j&&j <= 100005) { cout << j << endl; cout << i << endl; return 0; } } } if (n == 3) { FOR(i, m + 1, 100005) { FOR(j, m + 1, 100005) { if (i == j)continue; int k = x ^ i; k ^= j; if (k == i || k == j)continue; if (m < k&&k <= 100005) { cout << i << endl; cout << j << endl; cout << k << endl; return 0; } } } } if (n == 4) { FOR(i, m + 1, 100005)FOR(j, i + 1, 100005)FOR(k, j + 1, 100005) { int l = x ^ i^j^k; if (i == l || j == l || k == l)continue; if (k < l&&l <= 100005) { cout << i << endl; cout << j << endl; cout << k << endl; cout << l << endl; return 0; } } } }