#include <stdio.h>

int main(void){
  int n[200]={}, d[200]={};
  int count[200][2] ={};
  int H=0 ,hmax=0 ,wmax=0 ,W=0 ,ans;
  int N, i;

  scanf("%d", &N);
  for(i = 1 ; i < N ; i++){
    scanf("%d %d", &n[i], &d[i]);
    count[n[i]][d[i] % 2] += 1;
  }

  for(i = 0 ; i < N ; i++){
    if(wmax < count[i][0]) wmax = count[i][0];
    if(hmax < count[i][1]) hmax = count[i][1];
  }

  printf("%d %d\n", (wmax+1), (hmax+1));
}