/*本题对每个节点存储其父节点,再进行回溯,
得出其所在的层数,并对该层数的宽度加一操作*/
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
int a[16], b[16];//a[i]中存放i的父节点,b[j]统计第j层的宽度
for(int i = 0; i <= 16; i++)
{
a[i] = 0;
b[i] = 0;
}
for(int i = 1; i <= n; i++)
{
int x, y;
cin >> x >> y;
a[x] = i; a[y] = i;
}
int width = 0, depth = 0;
for(int i = 1; i <= n; i++)
{
int k = 1;//存储i节点所在的层数
int F = a[i];
while(F != 0)
{
k++;
F = a[F];
}
b[k]++;//i节点处于第k层,第k层的宽度加一
if(width < b[k]) width = b[k];
if(depth < k) depth = k;
}
cout << width << " " << depth << endl;
}
}