#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1000;
int steps[N];
int n;
int nums = 1;
struct nd
{
int ll, rr, st, ed, step;
}ar[N];
void add(int a, int b)
{
if (!ar[a].ll)
ar[a].ll = b;
else
ar[a].rr = b;
ar[b].step = ar[a].step + 1;
steps[ar[a].step + 1]++;
}
void init(int x)
{
if (!x) return;
ar[x].st = nums++;
init(ar[x].ll);
init(ar[x].rr);
ar[x].ed = nums++;
}
int a, b;
int main()
{
cin >> n;
int st = 0;
for(int i = 1; i < n; i ++)
{
cin >> a >> b;
if (!st) st = a;
add(a, b);
}
init(st);
cin >> a >> b;
//for (int i = 1; i <= n; i++) cout << "st = " << ar[i].st << " ** " << "ed = " << ar[i].ed << endl;
int xi = 0;
int max_step = 0, depth = 0;
for (depth = 1; steps[depth]; depth++)
max_step = max(max_step, steps[depth]);
for (int i = 1; i <= n; i++)
{
if (ar[i].st <= ar[a].st && ar[i].ed >= ar[a].ed && ar[i].st <= ar[b].st && ar[i].ed >= ar[b].ed &&(!xi || ar[xi].st <= ar[i].st && ar[xi].ed >= ar[i].ed))
xi = i;
}
cout << depth << endl;
cout << max_step << endl;
cout << 2 * abs(ar[xi].step - ar[a].step) + abs(ar[xi].step - ar[b].step);
return 0;
}