#include<stdio.h>
#include<stdlib.h>

int *s,*p,*deg,*dep,*h,*left,*right;

int main(){
  int n,i,j,k,id;

  scanf("%d",&n);

  s = (int *)malloc(n * sizeof(int));
  p = (int *)malloc(n * sizeof(int));
  deg = (int *)malloc(n * sizeof(int));
  dep = (int *)malloc(n * sizeof(int));
  h = (int *)malloc(n * sizeof(int));
  left = (int *)malloc(n * sizeof(int));
  right = (int *)malloc(n * sizeof(int));

  for(i = 0;i < n;i++){
    scanf("%d",&id);
    scanf("%d %d",&left[id],&right[id]);
    deg[i] = 0;
    dep[i] = 0;
    h[i] = 0;
    p[i] = -1;
    s[i] = -1;
  }

  for(i = 0;i < n;i++){
    if(left[i] >= 0 && right[i] >= 0){
      p[left[i]] = i;
      p[right[i]] = i;
      s[left[i]] = right[i];
      s[right[i]] = left[i];
      deg[i] = 2;
    }
    else if(left[i] >= 0 && right[i] < 0){
      p[right[i]] = i;
      deg[i]++;
    }
    else if(left[i] < 0 && right[i] >= 0){
      p[left[i]] = i;
      deg[i]++;
    }
  }

  for(i = 0;i < n;i++){
    j = i;
    while(1){
      if(p[j] == -1)break;
      dep[i]++;
      j = p[j];
    }
  }

  for(i = 0;i < n;i++){
    if(left[i] == -1 && right[i] == -1)continue;
    j = i;
    k = i;
    while(1){
      if(left[j] < 0 && right[j] < 0 && left[k] < 0 && right[k])break;
      h[i]++;
      j = left[j];
      k = right[k];
    }
  }

  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,p[i],s[i]);
    printf("degree = %d,depth = %d,height = %d, ",deg[i],dep[i],h[i]);
    if(p[i] == -1){
      printf("root\n");
    }
    else if(p[i] != -1 && h[i] != 0){
      printf("internal node\n");
    }
    else{
      printf("leaf\n");
    }
  }

  free(s);
  free(p);
  free(deg);
  free(dep);
  free(h);
  free(left);
  free(right);

  return 0;
}