#include <stdio.h>
#define NIL -1
int Depth (int );
int High(int );

struct Node{
  int id,parent,sibling,degree,depth,height,left,right;
};

struct Node node[25];




int main(){
  int i,n;


  scanf("%d",&n);
  for(i = 0 ; i < n ; i++)node[i].parent = node[i].sibling = node[i].degree = NIL;

  for(i = 0 ; i < n ; i++)
    {
      scanf("%d%d%d",&node[i].id, &node[i].left, &node[i].right);
      if(node[i].left != NIL && node[i].right != NIL)node[i].degree = 2;
      else {node[i].degree = 0;}
     
   
  

      node[node[i].right].sibling = node[i].left;
      node[node[i].right].parent = node[i].id;

      node[node[i].left].sibling  = node[i].right;
      node[node[i].left].parent = node[i].id;



    

    }

  for(i  =  0 ; i < n ; i++){


    node[i].depth = Depth(i);
    node[i].height = High(i);
  }




  for(i = 0 ; i < n ; i ++){

    printf("node %d: parent = %d, sibling =  %d, degree = %d, depth = %d, height = %d, "
	   ,i, node[i].parent, node[i].sibling, node[i].degree, node[i].depth, node[i].height);


    if(node[i].degree == 0 && node[i].parent != NIL)printf("leaf\n");
  
  
    else  if(node[i].parent == NIL)printf("root\n");

    //else if(node[i].parent != NIL && node[i].sibling != NIL)printf("internal node\n");
    else printf("internal node\n");





  }
  return 0;

}


int Depth (int k){

  int dep;

  for(dep = 0 ; node[k].parent != NIL ; dep++)
    {
      k = node[k].parent;
    }

  return dep;
}

int High (int k){
  int R,L,i,j;
  R = L = k;

  
  for(i = 0 ; node[L].left != NIL ; i++)
    {
      L = node[L].left;
    }
  for(j = 0 ; node[R].right != NIL ; j++)
    {
      R = node[R].right;
    }
  if(i > j)return i;
  else return j;

}