#include<bits/stdc++.h>
#include "cave.h"
using namespace std;
typedef long long ll;
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int n;
const int maxN=5000 + 15;
int a[maxN],b[maxN];
int con[maxN];
int tryCombination(int s[]);
void answer(int S[],int D[]);
void exploreCave(int n){
//subtask 2
int s[n];
for(int i=0;i<n;i++) s[i]=0;
int d[n];
int combi[n];
for(int i=0;i<n;i++) combi[i]=1;
for(int i=0;i<n;i++){
if(i==n-1){
//for(int j=0;j<n;j++) cout<<combi[i]<<' ';
//cout<<endl;
}
for(int j=0;j<n;j++){
if(combi[j]==0) continue;
combi[j]=0;
int see=tryCombination(combi);
if(see==i+1||see==-1){
d[j]=i;
break;
}
combi[j]=1;
}
}
answer(s,d);
}