#include <stdio.h>
#include <stdlib.h>

typedef struct{
  int parent;
  int left;
  int right;
}Node;

Node *T;
int n;

void maigoCenter(void);
int findSibling(int);
int countDegree(int);
int findDepth(int);
int findHeight(int);
void printType(int);

int main(){
  int i, id;

  scanf("%d", &n);

  T = malloc(sizeof(Node) * n);

  for(i=0; i<n; i++){
    T[i].parent = -1;
    scanf("%d%d%d", &id, &T[i].left, &T[i].right);
  }

  maigoCenter();

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, ", i, T[i].parent, findSibling(i));
    printf("degree = %d, depth = %d, height = %d, ", countDegree(i), findDepth(i), findHeight(i));
    printType(i);
  }

  return 0;
}

void maigoCenter(void){
  int i;

  for(i=0; i<n; i++){
    if(T[i].left != -1){
      T[T[i].left].parent = i;
    }
    if(T[i].right != -1){
      T[T[i].right].parent = i;
    }
  }

} 

int findSibling(int n){
  if(T[n].parent != -1){
    if(T[T[n].parent].left == n){
      return T[T[n].parent].right;
    }else {
      return T[T[n].parent].left;
    }
  }
    return -1;
}

int countDegree(int n){
  int count = 0 ;

  if(T[n].left != -1) count++;
  if(T[n].right != -1) count++;

  return count;
}

int findDepth(int n){
  int i, parent;

  if(T[n].parent == -1) return 0;

  parent = T[n].parent;

  for( i = 1; T[parent].parent != -1; i++){
    parent = T[parent].parent;
  }

  return i;
}

int findHeight(int n){
  int left, right;

  if(T[n].left == -1 && T[n].right == -1) return 0;

  left = findHeight(T[n].left);
  right = findHeight(T[n].right);

  return (left > right ? left+1 : right+1);

}

void printType(int n){
  if(T[n].parent == -1) printf("root\n");
  else if(T[n].left == -1 && T[n].right == -1) printf("leaf\n");
  else printf("internal node\n");
}