#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define vll vector<ll>
#define vbool vector<bool>
#define pairll pair<ll, ll>
#define pb push_back
#define fi first
#define sc second
void exploreCave(int n) {
// cout << n << endl;
int res[n];
int ans[n];
for(ll i = 0; i < n; i++) res[i] = ans[i] = -1;
int q[n];
for(ll cur = 0; cur < n; cur++){
ll res1 = 0, res2 = 0;
for(ll pw = 0; pw < 11; pw++){
for(ll i = 0; i < n; i++){
q[i] = ((i & (1 << pw)) && true);
if(ans[i] != -1)q[i] = ans[i];
}
ll k = tryCombination(q);
// cout << pw << endl;
// for(ll j = 0; j < n; j++) cout << q[j] << ' ';
// cout << endl;
if(k == -1)k = n;
if(k > cur){
res1 += (1 << pw);
}else{
res2 += (1 << pw);
}
}
// cout << res1 << ' ' << res2 << endl;
for(ll i = 0; i < n; i++){
if(ans[i] != -1){q[i] = ans[i]; continue;}
if(res1 == i)q[i] = 1;
if(res2 == i)q[i] = 1;
}
ll k = tryCombination(q);
if(k == -1)k = n;
if(k > cur){
if(res1 >= 1024){
ans[res2] = 0;
res[res2] = cur;
}else{
ans[res1] = 1;
res[res1] = cur;
}
}else{
if(res1 >= 1024){
ans[res2] = 0;
res[res2] = cur;
}else{
ans[res1] = 1;
res[res1] = cur;
}
}
// for(ll i = 0; i < n; i++) cout << ans[i] << ' ';
// cout << endl << endl;
}
// for(ll i = 0; i < n; i++){
// cout << ans[i] << ' ';
// }cout << endl;
// for(ll i = 0; i < n; i++){
// cout << res[i] << ' ';
// }cout << endl;
answer(ans, res);
}