rt,玄关
#include<bits/stdc++.h>
using namespace std;
struct tre{
int f=0,p=0,nu=0;
bool c=0;
}t[100];
int n,u,v,x,y;
int w,dep,dis,q[100];
void dfs(int r,int num,bool ud){
if(t[r].c==0)t[r].c=1;
else {
cout<<t[r].nu+num;
return ;
}
if(ud==0&&r!=1){
t[r].nu=num;
num+=2;
dfs(t[r].f,num,0);
}
else if(r==1&&ud==0){
t[r].nu=num;
dfs(y,0,1);
}
else if(ud==1&&r!=1){
t[r].nu=num;
num+=1;
dfs(t[r].f,num,1);
}
return ;
}
int main(){
cin>>n;
t[1].p=1;
for(int i=1;i<n;i++){
cin>>u>>v;
t[v].f=u;
t[v].p=t[u].p+1;
q[t[v].p]++;
w=max(w,q[t[v].p]);
dep=max(dep,t[v].p);
}
cin>>x>>y;
cout<<dep<<endl<<w<<endl;
dfs(x,0,0);
}