#include <stdio.h>
#define MAX 25

int getDepth(int);
int getHeight(int);

struct nibunki {
  int id;
  int parent;
  int sibling;
  int degree;
  int left;
  int right;
};

struct nibunki array[MAX];
int n, height[MAX];

int main(){
  int i, j, le, ri;

  scanf("%d", &n);

  for( i=0; i<n; i++){
    array[i].parent = array[i].left = array[i].right = array[i].sibling = -1;
    array[i].degree = 0;
  }

  for( i=0; i<n; i++){
    scanf("%d %d %d", &array[i].id, &le, &ri);
    array[i].left = le;
    array[i].right = ri;
    if( le != -1 ){
      array[le].parent = array[i].id;
      array[ri].parent = array[i].id;
      array[i].degree = 2;
    }
   }

  for( i=0; i<n; i++){
    for( j=0; j<n; j++){
      if( i != j && array[i].parent == array[j].parent ){
	array[i].sibling = array[j].id;
      }
    }
  }

  printf("\n\n");

  for( i=0; i<n; i++){
    printf("mode %d: left = %d, right = %d\n", array[i].id, array[i].left, array[i].right);
  }

  printf("\n\n");


  for( i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, ", 
	   array[i].id, array[i].parent, array[i].sibling, array[i].degree);
    
    printf("depth = %d, height = %d, ", getDepth(array[i].id), getHeight(array[i].id));

    if( array[i].parent == -1 ) printf("root\n");
    else if( array[i].left == -1 ) printf("leaf\n");
    else printf("internal node\n");

  }

  return 0;
}

int getDepth(int u){
  int d=0;

  while( array[u].parent != -1 ){
    u = array[u].parent;
    d++;
  }

  return d;
}

int getHeight(int u){
  int h1=0, h2=0;

  if( array[u].left != -1 ) h1 = getHeight(array[u].left) + 1;
  
  if( array[u].right != -1 ) h2 = getHeight(array[u].right) + 1;

  return height[u] = ( h1 > h2 ? h1 : h2 );
}