#include #include using namespace std; int N,X; vectorans; main() { cin>>N>>X; if(X<=3) { int id=8; while(N>4) { N-=4; ans.push_back(id++); ans.push_back(id++); ans.push_back(id++); ans.push_back(id++); } if(N==1)ans.push_back(X); else if(N==2) { ans.push_back(4); ans.push_back(4^X); } else if(N==3) { if(X%4==1) { ans.push_back(2); ans.push_back(4); ans.push_back(4^X^2); } else { ans.push_back(1); ans.push_back(4); ans.push_back(4^X^1); } } else { if(X%4==3) { ans.push_back(1); ans.push_back(3); ans.push_back(4); ans.push_back(4^X^1^3); } else { ans.push_back(1); ans.push_back(2); ans.push_back(4); ans.push_back(4^X^1^2); } } } else { int id=4; while(N>4) { if(id/4==X/4)id+=4; N-=4; ans.push_back(id++); ans.push_back(id++); ans.push_back(id++); ans.push_back(id++); } if(N==1)ans.push_back(X); else if(N==2) { ans.push_back(1); ans.push_back(X^1); } else if(N==3) { ans.push_back(1); ans.push_back(2); ans.push_back(X^1^2); } else { ans.push_back(1); ans.push_back(2); ans.push_back(3); ans.push_back(X); } } for(int a:ans)cout<