#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int n, r, a, maxd = -1, maxb = -1, book[500];
struct node {
int depth, left, right;
node(int d = 0, int left = 0, int right = 0)
:depth(0), left(0), right(0) {}
}t[110];
void build(int root, int Node) {
if (!t[root].left) {
t[root].left = Node;
t[Node].depth = t[root].depth + 1;
}
else {
t[root].right = Node;
t[Node].depth = t[root].depth + 1;
}
book[t[Node].depth]++;
maxd =(t[Node].depth>=maxd?t[Node].depth:maxd);
return;
}
int find(int x,int y) {
return t[x].depth * 2 + t[y].depth;
}
int main() {
t[0] = 1;
cin >> n;
for (int i = 0; i < n-1; i++) {
cin >> r >> a;
build(r, a);
}
cin >> r >> a;
cout << maxd+1 << endl;
for (int i = 0; i < 500; i++) {
maxb = (book[i] >= maxb ? book[i] : maxb);
}
cout << maxb << endl;
cout << find(r, a);
}