#include<stdio.h>
typedef struct{
  int number;
  int son[2];//子
  int reach;
  int parent;
  int sibling;
  int degree;
  int height;
}node;

node B[10000];
int n;

int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<2;j++){
      if(num==B[i].son[j]){
	r=i;
	return r;
      }
    }
  }
  return r;
}

int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}

int sibling(int num){//sibling input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    if(i!=num){
      if(B[num].parent==B[i].parent){
	r=i;
	return r;
      }
    }
  }
  return r;
}

int height(int num,int r){//height input
  //  printf("r = %d num = %d\n",r,num);
  
  if(B[num].son[0]==-1)return r;
  r++;
  r=height(B[num].son[0],r);
  r=height(B[num].son[1],r); 
  return r;
}

int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&B[i].number);
    for(j=0;j<2;j++){
      scanf("%d",&B[i].son[j]);

      if(B[i].son[0]==-1)B[i].degree=0;
      else B[i].degree=2;
    }
  }
  
  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
  
  for(i=0;i<n;i++){
    B[i].sibling=sibling(i);
  }
  
  for(i=0;i<n;i++){
    B[i].height=height(i,0);
    if(B[i].parent==-1)B[i].height--;
  }
 
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",B[i].number,B[i].parent,B[i].sibling,B[i].degree,B[i].reach,B[i].height);
    if(B[i].parent==-1)printf("root\n");
    else if(B[i].son[0]==-1)printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}