#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
int timer = -1;
void dfs(int node, int prev, vector<vector<int>> &adj, vector<int> &tin, vector<int> &tout) {
tin[node] = ++timer;
for (auto &neighbour : adj[node]) {
if (neighbour == prev) continue;
dfs(neighbour, node, adj, tin, tout);
}
tout[node] = timer;
}
int enc(int in, int out) {
return (in + out * (1 << 10));
}
pair<int, int> dec(int x) {
int tin = 0, tout = 0;
for (int i = 0; i <= 9; i++) {
tin += x & (1 << i);
}
for (int i = 10; i <= 19; i++) {
bool h = x & (1 << i);
if (h) tout += (1 << (i - 10));
}
return {tin, tout};
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> ans(n); vector<vector<int>> adj(n); vector<int> deg(n);
queue<int> q;
for (int i = 0; i < n - 1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
deg[u[i]]++; deg[v[i]]++;
}
for (int i = 0; i < n; i++) {
if (deg[i] == 1) {
q.push(i);
break;
}
}
int amt = 0;
while (!q.empty()) {
int cur = q.front();
q.pop();
ans[cur] = amt++;
for (auto &neighbour : adj[cur]) {
deg[neighbour]--;
if (deg[neighbour] == 1) q.push(neighbour);
}
}
return ans;
}
bool cont(pair<int, int> &a, pair<int, int> &b) {
if (a.first <= b.first && b.second <= a.second) return true;
else return false;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (s < t) return c[1];
else return c[0];
}