#include <stdio.h>
#include <string.h>
#define N 100000

struct Node{
  int parent;
  int left;
  int right;
};

int main(){
  
  int n,j,p,i,d,s,t,a,id,b,k,l,r,re,re1,sum,MAX=0;
  
  scanf("%d",&n);
  
  struct Node T[n];

  for(i=0;i<n;i++){
    T[i].right=T[i].left=T[i].parent=-1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&l,&r);
    T[id].left=l;
    T[l].parent=id;
    T[id].right=r;
    T[r].parent=id;

  }


  for(i=0;i<n;i++){
    if(T[i].parent==-1){
      printf("node %d: parent = -1, sibling = -1, degree = ",i);
      if(T[i].left!=-1&&T[i].right!=-1)
	printf("2, ");
      else if(T[i].left!=-1&&T[i].right==-1)
	printf("1,");
      else if(T[i].left==-1&&T[i].right!=-1)
	printf("1, ");
      else printf("0, ");

      printf("depth = 0, height = ");
      sum=0;
      re=T[i].left;
      re1=T[i].right;
      while(re!=-1){
	sum++;
	re=T[re].left;
	re1=T[re1].right;
      }
      if(re!=-1)
      printf("%d, root\n",sum+1);
    }
    
    else if(T[i].left==-1){
      s=0;
      b=T[i].parent;
      printf("node %d: parent = %d, sibling = ",i,T[i].parent);
      if(i==T[b].right)
	printf("%d, ",T[b].left);
      else printf("%d, ",T[b].right);

      printf("degree = ");
      if(T[i].left!=-1&&T[i].right!=-1)
	printf("2,");
      else if(T[i].left!=-1&&T[i].right==-1)
	printf("1,");
      else if(T[i].left==-1&&T[i].right!=-1)
	printf("1, ");
      else printf("0, ");
      printf("depth = ");
	
      a=T[i].parent;
      while(a!=-1){
	s++;
	a=T[a].parent;
      }
      printf("%d, height = ",s);
      
      sum=0;
      re=T[i].left;
      re1=T[i].right;
      while(re!=-1){
	sum++;
	re=T[re].left;
	re1=T[re1].right;
      }
      printf("%d, leaf\n",sum);
    }
    
    else{
      s=0;
      b=T[i].parent;
      
      printf("node %d: parent = %d, sibling = ",i,T[i].parent);
      if(i==T[b].right)
	printf("%d, ",T[b].left);
      else printf("%d, ",T[b].right);
      printf("degree = ");
      if(T[i].left!=-1&&T[i].right!=-1)
	printf("2, ");
      else if(T[i].left!=-1&&T[i].right==-1)
	printf("1,");
      else if(T[i].left==-1&&T[i].right!=-1)
	printf("1, ");
      else printf("0, ");
      printf("depth = ");
	
      a=T[i].parent;
      while(a!=-1){
	s++;
	a=T[a].parent;
      }
      
      printf("%d, height = ",s);
      sum=0;
      re=T[i].left;
      re1=T[i].right;
      while(re!=-1){
	sum++;
	re=T[re].left;
	re1=T[re1].right;
      }

      printf("%d, internal node\n",sum);
    }
  }
  return 0;
}