#include #include #include #define llint long long using namespace std; llint n, x; vector ans; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> x; if(n == 1){ cout << x << endl; return 0; } if(n == 2){ if(x == 1){ cout << 2 << endl; cout << 3 << endl; } else if(x == 2){ cout << 1 << endl; cout << 3 << endl; }else{ llint y = x ^ 1; cout << 1 << endl; cout << y << endl; } return 0; } llint rem = n; if(n % 4 == 0){ if(x > 3){ rem--; for(int i = 0; ; i++){ if(x/4 == i) continue; for(int j = 0; j < 4; j++){ if(i*4+j != 0 && rem) ans.push_back(i*4+j), rem--; } if(rem <= 0) break; } ans.push_back(x); } else{ rem -= 4; for(int i = 1; ; i++){ for(int j = 0; j < 4; j++){ if(i*4+j != 0 && rem) ans.push_back(i*4+j), rem--; } if(rem <= 0) break; } int t = 3; if(ans.size()) t = ans.back(); if(x != 1){ ans.push_back(t+1); ans.push_back(t+2); if(x == 0) ans.push_back(2), ans.push_back(3); if(x == 2) ans.push_back(1), ans.push_back(2); if(x == 3) ans.push_back(1), ans.push_back(3); } else{ ans.push_back(t+1); ans.push_back(t+3); ans.push_back(1), ans.push_back(2); } } } if(n % 4 == 1){ rem--; for(int i = 1; ; i++){ if(x/4 == i) continue; for(int j = 0; j < 4; j++){ if(i*4+j != 0 && rem) ans.push_back(i*4+j), rem--; } if(rem <= 0) break; } ans.push_back(x); } if(n % 4 == 2){ rem++; int i = x/4; for(int j = 0; j < 4; j++){ if(i*4+j != 0 && rem) ans.push_back(i*4+j), rem--; } for(int i = 0; ; i++){ for(int j = 0; j < 4; j++){ if(rem) ans.push_back(i*4+j), rem--; } if(rem <= 0) break; } for(int j = 0; j < ans.size(); j++){ if(ans[j] == x) ans.erase(ans.begin() + j); } } if(n % 4 == 3){ if(x > 3){ rem++; int i = x/4; for(int j = 0; j < 4; j++){ if(i*4+j != 0 && rem) ans.push_back(i*4+j), rem--; } for(int i = 1; ; i++){ for(int j = 0; j < 4; j++){ if(i*4+j != 0 && rem) ans.push_back(i*4+j), rem--; } if(rem <= 0) break; } for(int j = 0; j < ans.size(); j++){ if(ans[j] == x) ans.erase(ans.begin() + j); } } else{ rem -= 3; for(int i = 1; ; i++){ for(int j = 0; j < 4; j++){ if(rem) ans.push_back(i*4+j), rem--; } if(rem <= 0) break; } int t = 3; if(ans.size()) t = ans.back(); if(x != 1){ ans.push_back(t+1); ans.push_back(t+2); if(x == 0) ans.push_back(1); if(x == 2) ans.push_back(3); if(x == 3) ans.push_back(2); } else{ ans.push_back(t+1); ans.push_back(t+3); ans.push_back(3); } } } sort(ans.begin(), ans.end()); for(int i = 0; i < ans.size(); i++) cout << ans[i] << endl; return 0; }