/*
_ __ __ __ ____ ___ _ __
| | /| / / ___ _ / /_ ____ / / / __ \ ___ ___ / _ \ (_) ___ ____ ___ / /
| |/ |/ / / _ `// __// __/ / _ \ / /_/ / / _ \/ -_) / ___/ / / / -_)/ __// -_) /_/
|__/|__/ \_,_/ \__/ \__/ /_//_/ \____/ /_//_/\__/ /_/ /_/ \__/ \__/ \__/ (_)
*/
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
// #pragma GCC target("avx2")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define ld long double
#define all(v) v.begin(), v.end()
#define allr(v, l, r) v.begin() + l, v.begin() + r + 1
#define rall(v) v.rbegin(), v.rend()
#define rallr(v, l, r) v.rbegin() + ((int)v.size() - 1 - r), v.rbegin() + ((int)v.size() - l)
// #define endl "\n"
#define newline cout << endl;
using namespace std;
// constants
const int INF = 1e9;
// functions
// structs
struct graph
{
vector <vector <int> > g;
vector <bool> banished;
vector <int> sz;
void cleanse()
{
fill(all(sz), 0);
}
graph(int n)
{
g.resize(n + 1);
sz.resize(n + 1);
banished.assign(n + 1, false);
cleanse();
}
void adde(int u, int v)
{
g[u].push_back(v);
g[v].push_back(u);
}
void DFS(int v, int P)
{
sz[v] = 1;
for (auto u : g[v])
{
if (u == P || banished[u])
{
continue;
}
DFS(u, v);
sz[v] += sz[u];
}
}
void getp(int v, int P, vector <int> &path)
{
path.push_back(v);
for (auto u : g[v])
{
if (u == P || banished[u])
{
continue;
}
getp(u, v, path);
}
}
int getC(int v, int P, int limit)
{
for (auto u : g[v])
{
if (u == P || banished[u])
{
continue;
}
if (sz[u] > limit)
{
return getC(u, v, limit);
}
}
return v;
}
};
// globals
// notes
/*
-stuff you should look for-
* int overflow, array bounds
* special cases (n=1?)
* do something instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
continue - skip the rest in the loop
*/
void solve()
{
int n;
cin >> n;
graph G(n + 1);
for (int i = 1; i < n; i++)
{
int u, v;
cin >> u >> v;
G.adde(u, v);
}
auto query = [&](vector <int> nodes)
{
for (auto v : nodes)
{
cout << v << ' ';
}
newline
int x;
cin >> x;
return x;
};
function <int(int)> f = [&](int v)
{
G.DFS(v, -1);
if (G.sz[v] == 1)
{
return v;
}
v = G.getC(v, -1, G.sz[v] / 2);
G.DFS(v, -1);
vector <int> ns;
for (auto u : G.g[v])
{
if (!G.banished[u])
{
ns.push_back(u);
}
}
sort(all(ns), [&](const int &a, const int &b)
{
return G.sz[a] > G.sz[b];
});
vector <int> forq, cs;
int cur = 0;
for (auto u : ns)
{
if (cur + G.sz[u] <= G.sz[v] / 2)
{
cur += G.sz[u];
G.getp(u, v, forq);
cs.push_back(u);
}
}
if (forq.empty() && !ns.empty())
{
G.getp(ns[0], v, forq);
cs.push_back(ns[0]);
}
if (forq.empty())
{
return v;
}
if (query(forq))
{
G.banished[v] = true;
for (auto u : ns)
{
bool b = false;
for (auto z : cs)
{
if (u == z)
{
b = true;
break;
}
}
if (!b)
{
G.banished[u] = true;
}
}
return f(forq[0]);
}
else
{
for (auto u : cs)
{
G.banished[u] = true;
}
return f(v);
}
};
cout << f(1);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int testcount = 1;
// cin >> testcount;
while (testcount--)
{
solve();
newline
}
}
/*
$$$$$$$$\ $$$$$$$$\
$$ _____|\____$$ |
$$ | $$ /
$$$$$\ $$ /
$$ __| $$ /
$$ | $$ /
$$$$$$$$\ $$$$$$$$\
\________|\________|
*/