#include<bits/stdc++.h>
using namespace std;
struct node{
int par;
int lc;
int rc;
int depth;
};
int dep[105];
node root[105];
int cal(int t,int b,int ans){
if(t==b){
return ans;
}
else{
if(root[b].par!=0){
return cal(t,root[b].par,ans+1);
}
}
return 150;
}
int main(){
int n;
cin>>n;
root[1].depth=1;
dep[1]=1;
int a,b;
for(int i=1;i<n;i++){
cin>>a>>b;
if(root[a].lc==0){
root[a].lc=b;
root[b].depth=root[a].depth+1;
root[b].par=a;
dep[root[b].depth]++;
}
else if(root[a].rc==0){
root[a].rc=b;
root[b].depth=root[a].depth+1;
root[b].par=a;
dep[root[b].depth]++;
}
}
int answ,ansd;
for(int i=1;i<=n;i++){
if(dep[i]==0)break;
answ=max(answ,dep[i]);
ansd=i;
}
cin>>a>>b;
int t=a,s1=0;
cout<<ansd<<endl<<answ<<endl;
while(t!=0){
if(cal(t,b,0)!=150){
cout<<s1+cal(t,b,0);
break;
}
t=root[t].par;
s1+=2;
}
}