#include <stdio.h>
#define N 25
 
typedef struct{
  int id;
  int sibling;
  int parent;
  int right;
  int left;

} Node;

int CheckHeight(Node *, int);

int main(){
  int i, n;
  int id, right, left, depth, parent;
  Node node[N];
 
  scanf("%d", &n);
 
  for(i = 0; i < n;  i++){
    node[i].sibling = -1;
    node[i].parent = -1;
  }
 
  for( i = 0; i < n; i++){
    scanf("%d%d%d", &id, &left, &right);
 
    node[id].id = id;
    node[id].right = right;
    node[id].left = left; 

    if(right != -1 || left != -1){
      node[right].parent = id;
      node[left].parent = id;
      node[right].sibling = left;
      node[left].sibling = right;
    }
  }
 
  for( i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, ", node[i].id, node[i].parent, node[i].sibling);
 
    if( node[i].right == -1 && node[i].left == -1 ) printf("degree = 0, ");
    else if( node[i].right == -1 || node[i].left == -1 ) printf("degree = 1, ");
    else printf("degree = 2, ");
 
    depth = 0;
    parent = node[i].parent;
    while(1){
      if(parent == -1) break;
      else {
        parent = node[parent].parent;
        depth++;
      }
    }
 
    printf("depth = %d, ", depth);
 
    printf("height = %d, ", CheckHeight(node, i));
 
    if( node[i].parent == -1 ) printf("root");
    else if( node[i].left == -1 && node[i].right == -1) printf("leaf");
    else printf("internal node");
    printf("\n");
  }
 
  return 0;
} 

int CheckHeight(Node node[], int i){
  int left, right, height = 0;
 
  if(node[i].right == -1 && node[i].left == -1 ) return height;
  else if( i == -1 ) return height;

  right = CheckHeight(node, node[i].right); 
  left = CheckHeight(node, node[i].left);

  if( left > right ) return left + 1;
  else return right + 1;
 
}