#include <cstdio>
#include <vector>
#include "library.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
vector<int> res;
set<int> rem;
int n;
int query(vector<int> &test)
{
int ex1=0;
for(int i=0;i<n;i++)
{
if(test[i]) ex1=1;
}
if(!ex1) return 0;
else return Query(test);
}
void solve(int l, int r)
{
//cerr<<"SOLVE "<<l<<' '<<r<<'\n';
if(l>r) return ;
if(l==r)
{
res[l] = (*rem.begin()); return ;
}
int xr=0;
for(int i=0;i<10;i++)
{
vector<int> test(n,0);
for(int x:rem)
{
if(x&(1<<i))
{
test[x]=1;
}
}
int res = query(test);
test.assign(n,0);
for(int x:rem)
{
if(!(x&(1<<i)))
{
test[x]=1;
}
}
int res2 = query(test);
if(res==res2)
{
xr^=(1<<i);
}
}
set<int> possibleX; vi V;
for(int x:rem)
{
if(possibleX.find(x^xr)==possibleX.end())
{
possibleX.insert(x); V.pb(x);
}
}
int lo=0; int hi=int(V.size())-1;
int ans = -1;
while(lo<=hi)
{
int mid=(lo+hi)>>1;
vector<int> test(n,0);
for(int i=0;i<V.size();i++)
{
if(i<=mid) test[V[i]]=1;
else test[V[i]]=0;
}
int ans1 = query(test);
for(int x:rem)
{
test[x]^=1;
}
int ans2=query(test);
if(ans1==ans2)
{
ans=mid;
hi=mid-1;
}
else lo=mid+1;
}
//cerr<<"XOR : "<<xr<<'\n'; //cerr<<"ANS : "<<ans<<'\n';
int x = V[ans]; int y = V[ans]^xr;
if(l>0)
{
vector<int> test(n,0);
test[res[l-1]]=1; test[x]=1;
if(query(test)!=1)
{
swap(x,y);
}
}
res[l] = x; res[r] = y;
//cerr<<l<<' '<<x<<'\n'; //cerr<<r<<' '<<y<<'\n';
rem.erase(x); rem.erase(y);
solve(l+1,r-1);
}
void Solve(int N)
{
n=N;
res.resize(N);
for(int i=0;i<N;i++) rem.insert(i);
solve(0,N-1);
for(int i=0;i<N;i++) res[i]++;
Answer(res);
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgImxpYnJhcnkuaCIKI2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxleHQvcGJfZHMvYXNzb2NfY29udGFpbmVyLmhwcD4KI2luY2x1ZGUgPGV4dC9wYl9kcy90cmVlX3BvbGljeS5ocHA+CiAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdXNpbmcgbmFtZXNwYWNlIF9fZ251X3BiZHM7CiAKI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIG1wIG1ha2VfcGFpcgojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIGZibyBmaW5kX2J5X29yZGVyCiNkZWZpbmUgb29rIG9yZGVyX29mX2tleQogCnR5cGVkZWYgbG9uZyBsb25nIGxsOwp0eXBlZGVmIHBhaXI8bGwsbGw+IGlpOwp0eXBlZGVmIHZlY3RvcjxpbnQ+IHZpOwp0eXBlZGVmIGxvbmcgZG91YmxlIGxkOyAKdHlwZWRlZiB0cmVlPGxsLCBudWxsX3R5cGUsIGxlc3M8bGw+LCByYl90cmVlX3RhZywgdHJlZV9vcmRlcl9zdGF0aXN0aWNzX25vZGVfdXBkYXRlPiBwYmRzOwp0eXBlZGVmIHNldDxsbD46Oml0ZXJhdG9yIHNpdDsKdHlwZWRlZiBtYXA8bGwsbGw+OjppdGVyYXRvciBtaXQ7Cgp2ZWN0b3I8aW50PiByZXM7CnNldDxpbnQ+IHJlbTsKaW50IG47CgppbnQgcXVlcnkodmVjdG9y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