#include<stdio.h>

typedef struct{
  int id;
  int r;
  int l;
  int deg;
  int s;
  int parent;
  int dep;
  int h;
}Tree;

main(){
  int a,i,j,g,x,y,count,max;
  Tree node[25];
  scanf("%d",&g);
  for(i=0;i<g;i++){
    scanf("%d",&a);
    node[a].id=a;
    scanf("%d%d",&node[a].l,&node[a].r);
  }
  
   for(i=0;i<g;i++){
     count=0;
    for(j=0;j<g;j++){
      if(node[i].id==node[j].l || node[i].id == node[j].r){
	  node[i].parent=node[j].id;
          count++;
	  break;
      }
      if(count>0)break;
      else node[i].parent = -1;
    }}

   for(i=0;i<g;i++){
     for(j=0;j<g;j++){
       if(node[i].parent == -1)node[i].s =-1;
       else if(node[i].parent == node[j].parent){
	 node[i].s =node[j].id;
	 node[j].s =node[i].id;
	 break;
       }
	}}

   for(i=0;i<g;i++){
     if(node[i].l==-1 && node[i].r==-1)node[i].deg=0;
     else node[i].deg=2;
   }

   for(i=0;i<g;i++){
    node[i].dep=0;
    if(node[i].parent==-1)continue;
    if(node[i].parent>=0)node[i].dep++;
    x=node[i].parent;
    while(1){
      if(node[x].parent>=0){
	node[i].dep++;
	x = node[x].parent;
      }
      else  break;
    }
  }
   max = -999;
   for(i=0;i<g;i++){
     if(max<node[i].dep)max=node[i].dep;}

   for(i=0;i<g;i++){
     node[i].h=0;
     if(node[i].deg==0)continue;
     else{
       x = node[i].l;
       y = node[i].r;
       while(1){
	 if(node[x].deg>0 && node[y].deg>0){
	   node[i].h = max - node[i].dep;
	 break;
	 }
	 else if(node[x].deg==0 && node[y].deg == 0){
	   node[i].h++;
	   break;
	 }
	 else if(node[x].deg>0 && node[y].deg == 0){
	   node[i].h++;
	   x = node[x].l;
	   y = node[x].r;
	 }
	  else if(node[x].deg==0 && node[y].deg>0){
	   node[i].h++;
	   x = node[y].l;
	   y = node[y].r;
	 }
       }}}
	 
       
   for(i=0;i<g;i++){
     printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",node[i].id,node[i].parent,node[i].s,node[i].deg,node[i].dep,node[i].h);
   if(node[i].dep==0)printf("root\n");
   else if(node[i].h==0)printf("leaf\n");
   else printf("internal node\n");
   
   }
   return 0;
}