#include<bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int N)
{
vector<int> x;
vector<int> m;
vector<int> ans;
int x1;
m.assign(N,1);
for (int i = 0;i<N;i++) x.push_back(i+1);
for (int i =0;i<N;i++){
m[i] = 0;
if (Query(m)==1){if (i<N) x.erase(x.begin()+i);ans.push_back(i+1);break;}
m[i] = 1;
}
m.assign(N,0);
if (ans.size()==N) {Answer(ans);return;}
for (int i = 0;i<N;i++){
int a = 0;
if (x.empty()) break;
int b = x.size()-1;
while (a!=b){
int y = (a+b)/2;
if (!ans.empty() and ans[ans.size()-1]-1<N) m[ans[ans.size()-1]-1 ]=1;
for (int j = a;j<=y;j++) {if (j<x.size() and j>0 and x[j]-1<N ) m[x[j]-1] = 1;}
int z = Query(m);
if (!ans.empty() and ans[ans.size()-1]-1<N) m[ans[ans.size()-1]-1] = 0;
int z1 = Query(m);
if (z==z1) b = y;
else a = y+1;
m.assign(N,0);
}
if (x.empty()) break;
if (b<x.size()) ans.push_back(x[b]);
if (ans.size()==N) break;
if (b<x.size()) x.erase(x.begin()+b);
m.assign(N,0);
}
Answer(ans);
}