#include<bits/stdc++.h>
using namespace std;
int n , s1 , s2 , maxDepth , maxLayer , dis , d1 , d2;
struct node{
	int lchild , rchild;
}e[105];
int a[105];
void DFS(int root , int depth)
{
	if(root == 0){
		maxDepth = max(maxDepth , depth - 1);
		return;
	}
	if(root == s1){
		d1 = (depth - 1) * 2;
	}
	if(root == s2){
		d2 = depth - 1;
	}
	a[depth] ++;
	DFS(e[root].lchild , depth + 1);
	DFS(e[root].rchild , depth + 1);
}
int main()
{
	cin >> n;
	for(int i = 1;  i <= n - 1; i ++){
		int root , child;
		cin >> root >> child;
		if(e[root].lchild == 0){
			e[root].lchild = child;
		}else{
			e[root].rchild = child;
		}
	}
	cin >> s1 >> s2;
	DFS(1 , 1);
	for(int i = 1 ; i <= 100 ; i ++){
		maxLayer = max(maxLayer , a[i]);
	}
	printf("%d\n%d\n%d" , maxDepth , maxLayer , d1 + d2);
	return 0;
}