#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 100010
ll dead[maxn], sz[maxn];
vector <ll> g[maxn];
vector <ll> cen_tree[maxn];
void get_sz(ll src, ll par)
{
sz[src]=1;
for(auto x: g[src])
{
if(x==par || dead[x]==1) continue;
get_sz(x, src);
sz[src]+=sz[x];
}
}
ll find_centroid(ll src)
{
while(1)
{
ll mx=0, v=-1;
for(auto x: g[src])
{
if(dead[x]==1) continue;
if(sz[x]>mx) mx=sz[x], v=x;
}
if(mx<=sz[src]/2) return src;
sz[src]-=mx;
sz[v]+=sz[src];
src=v;
}
return src;
}
void form_tree(ll src)
{
get_sz(src, -1LL);
src=find_centroid(src);
dead[src]=1;
queue <ll> q;
q.push(src);
while(q.size())
{
ll x=q.front();
q.pop();
for(auto h: g[x])
{
if(dead[h]==1) continue;
ll c=find_centroid(h);
dead[c]=1;
cen_tree[x].push_back(c);
q.push(c);
}
}
}
int main()
{
ll x, i, j, m, n, u, v;
scanf("%lld", &n);
for(i=0; i<n-1; i++)
{
scanf("%lld %lld", &u, &v);
g[u].push_back(v);
g[v].push_back(u);
}
form_tree(1LL);
for(i=1; i<=n; i++)
{
printf("%lld: ", i);
for(auto x: cen_tree[i]) printf("%lld ", x);
printf("\n");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nIAojZGVmaW5lIG1heG4gMTAwMDEwCmxsIGRlYWRbbWF4bl0sIHN6W21heG5dOwp2ZWN0b3IgPGxsPiBnW21heG5dOwp2ZWN0b3IgPGxsPiBjZW5fdHJlZVttYXhuXTsKdm9pZCBnZXRfc3oobGwgc3JjLCBsbCBwYXIpCnsKCXN6W3NyY109MTsKCWZvcihhdXRvIHg6IGdbc3JjXSkKCXsKCQlpZih4PT1wYXIgfHwgZGVhZFt4XT09MSkgY29udGludWU7CgkJZ2V0X3N6KHgsIHNyYyk7CgkJc3pbc3JjX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