#include "fun.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <math.h>
#include <iomanip>
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define upmax(a, b) a = max(a, b)
#define upmin(a, b) a = min(a, b)
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;
vvll tree;
vector<int> createFunTour(int N, int Q) {
ll n = N, q = Q;
tree.clear(), tree.resize(n);
vector<set<pll>> paths(n);
vector<pair<ll, pll>> arr;
ll max_len = -1;
ll start_node = -1;
rep(i, 0, n) {
rep(j, i + 1, n) {
ll len = hoursRequired(i, j);
paths[i].insert({ -len, j });
paths[j].insert({ -len, i });
upmax(max_len, len);
if (max_len == len) {
start_node = i;
}
if (len == 1) {
tree[i].push_back(j);
tree[j].push_back(i);
}
}
}
vector<int> ans;
ll cur_node = start_node;
while (ans.size() < n) {
ans.push_back(cur_node);
for (auto& it : paths[cur_node]) {
ll nei = it.second;
ll len = it.first;
paths[nei].erase({ len, cur_node });
}
if (!paths[cur_node].empty()) cur_node = (*paths[cur_node].begin()).second;
}
return ans;
int H = hoursRequired(0, N - 1);
int A = attractionsBehind(0, N - 1);
return vector<int>(N);
}
/*
7 400000
0 1
0 5
0 6
1 2
1 4
2 3
*/