#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 void Out(vector p){ rep(i,p.size()){ if(i!=0)cout<<' '; cout<>n; vector a(n); rep(i,n)cin>>a[i]; if(n<=8){ vector p(n); rep(i,n)p[i] = i+1; map> mp; do{ int s = 0; rep(i,n)s ^= a[i] + p[i]; if(mp.count(s)){ Out(p); Out(mp[s]); return 0; } else mp[s] = p; } while(next_permutation(p.begin(),p.end())); cout<<-1<> is(4); rep(i,n)is[a[i]%4].push_back(i); vector p(n,-1),q(n,-1); set s; rep(i,n)s.insert(i); if(is[0].size() + is[2].size()>=2){ vector t; rep(i,is[0].size())t.push_back(is[0][i]); rep(i,is[2].size())t.push_back(is[2][i]); while(t.size()>=3)t.pop_back(); p[t[0]] = 0; p[t[1]] = 1; s.erase(0); s.erase(1); rep(i,n){ if(p[i]==-1){ p[i] = *s.begin(); s.erase(s.begin()); } } q = p; swap(q[t[0]],q[t[1]]); rep(i,n){ p[i]++,q[i]++; } Out(p); Out(q); } else if(is[0].size() + is[1].size()>=2){ vector t; rep(i,is[0].size())t.push_back(is[0][i]); rep(i,is[1].size())t.push_back(is[1][i]); while(t.size()>=3)t.pop_back(); p[t[0]] = 0; p[t[1]] = 2; s.erase(0); s.erase(2); rep(i,n){ if(p[i]==-1){ p[i] = *s.begin(); s.erase(s.begin()); } } q = p; swap(q[t[0]],q[t[1]]); rep(i,n){ p[i]++,q[i]++; } Out(p); Out(q); } else{ vector t; rep(i,is[3].size())t.push_back(is[3][i]); while(t.size()>=3)t.pop_back(); p[t[0]] = 1; p[t[1]] = 3; s.erase(1); s.erase(3); rep(i,n){ if(p[i]==-1){ p[i] = *s.begin(); s.erase(s.begin()); } } q = p; swap(q[t[0]],q[t[1]]); rep(i,n){ p[i]++,q[i]++; } Out(p); Out(q); } } return 0; }