#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int n,u,v,x,y,wide=0,deep=0;
int width[10005];
int tree[20005],pos[20005];
int find(int crt,int dis,bool from_root)
{
if(tree[crt]==0) return 0;
else if(tree[crt]==y)
{
cout<<dis<<endl;
return 1;
}
else return find(crt*2,dis+1,1)||find(crt*2+1,dis+1,1)||(!from_root&&find(crt/2,dis+2,0));
}
int main()
{
memset(tree,0,sizeof(tree));
memset(width,0,sizeof(width));
tree[1]=1;pos[1]=1;
cin>>n;
for(int i=1;i<=n-1;++i)
{
cin>>u>>v;
pos[v]=tree[pos[u]*2]?pos[u]*2+1:pos[u]*2;
tree[pos[v]]=v;
int depth=log2(pos[v])+1;
deep=deep>depth?deep:depth;
wide=wide>++width[depth]?wide:width[depth];
}
cin>>x>>y;
cout<<deep<<endl<<wide<<endl;
find(pos[x],0,0);
return 0;
}