#include<stdio.h>
   
#define MAX 100000
#define NIL -1
   
typedef struct{
  int parent, left, right, depth, height, deg;
}Node;
   
Node n[MAX];
int num;
   
void calcDepth(int,int);
int calcHeight(int);
int getSibling(int);
 
int main(){
  int i, node, left, right, root = 0;
   
  scanf("%d",&num);
    
  for(i = 0;i < num;i++){
    n[i].parent = NIL;
  }
  for(i = 0;i < num;i++){
    scanf("%d %d %d",&node,&left,&right);
    n[node].left = left;
    n[node].right = right;
    if(left != NIL) n[left].parent = node;
    if(right != NIL) n[right].parent = node;
  }
   
  for(i = 0;i < num;i++){
    if(n[i].parent == NIL) root = i;
  }
    
  calcDepth(root,0);
  calcHeight(root);
   
  for(i = 0;i < num;i++){
    n[i].deg = 0;
    printf("node %d: parent = %d, sibling = %d, ",i,n[i].parent,getSibling(i));
      
    if(n[i].left != NIL) n[i].deg++;
    if(n[i].right != NIL) n[i].deg++;
   
    printf("degree = %d, depth = %d, height = %d, ",n[i].deg,n[i].depth,n[i].height);
   
    if(n[i].parent == NIL) printf("root\n");
    else if(n[i].left == NIL && n[i].right == NIL) printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

void calcDepth(int u, int d){
   
  if(u == NIL) return;
  n[u].depth = d;
  calcDepth(n[u].left,d+1);
  calcDepth(n[u].right,d+1);
}
   
int calcHeight(int u){
  int h1,h2;
   
  h1 = h2 = 0;
  if(n[u].left != NIL) h1 = calcHeight(n[u].left) + 1;
  if(n[u].right != NIL) h2 = calcHeight(n[u].right) + 1;
  if(h1 > h2) n[u].height = h1;
  else return n[u].height = h2;
}
   
int getSibling(int u){
   
  if(n[u].parent == NIL)return NIL;
 
  if(n[n[u].parent].left != u && n[n[u].parent].left != NIL)
    return n[n[u].parent].left;
 
  if(n[n[u].parent].right != u && n[n[u].parent].right != NIL)
    return n[n[u].parent].right;
 
  return NIL;
}