#include using namespace std; vector solveB(int); vector solveA(int N){ if(N == 1) return {0, 0, 0}; if(N == 5) return {0, 1, 2, 3, 0, 4, 1, 2, 0, 3, 1, 4, 3, 4, 2}; vector res; int mx = N-1, mn = N/2; if(N%2){ for(int i=mx; i>=mn; i--) for(int t=0; t<2; t++) res.push_back(i); for(int i=mx; i>=mn; i--) res.push_back(i); for(int a : solveA(N/2)) res.push_back(a); }else{ for(int i=mn; i<=mx; i++) res.push_back(i); res.push_back(mx); for(int i=mn; i solveB(int N){ if(N == 3) return {0, 1, 2, 0, 1, 2, 2, 0, 1}; if(N == 4) return {0, 1, 2, 0, 3, 1, 2, 0, 2, 3, 1, 3}; vector res; int mx = N-1, mn = N/2; if(N%2){ res = solveB(N/2); for(int i=mx; i>=mn; i--) for(int t=0; t<2; t++) res.push_back(i); for(int i=mx; i>=mn; i--) res.push_back(i); }else{ res.push_back(mx); for(int i=mx-1; i>=mn; i--) for(int t=0; t<2; t++) res.push_back(i); res.push_back(mx); for(int i=mx; i>=mn; i--) res.push_back(i); for(int a : solveA(N/2)) res.push_back(a); } return res; } int main(){ int N; cin >> N; if(N == 2){ cout << -1 << endl; return 0; } auto ans = solveA(N); int sz = ans.size(); for(int i=0; i> pos(N); for(int i=0; i