1 #include<cstdio>
2 int n,a,b,ans,kd,cs[30],dc[30];
3 int main(){
4 scanf("%d",&n);cs[0]=1;
5 for(int i=1;i<=n;i++){
6 scanf("%d%d",&a,&b);
7 if(a){dc[a]=dc[i]+1;++cs[dc[a]];}
8 if(b){dc[b]=dc[i]+1;++cs[dc[b]];}
9 }
10 for(ans=0;ans<30;ans++){
11 if(!cs[ans]) break;
12 if(cs[ans]>kd) kd=cs[ans];
13 }
14 printf("%d %d",kd,ans);
15 return 0;
16 }