#include <stdio.h>

void Depth(int, int);
int Height(int);
int Sibling(int);
void print(int);

typedef struct{
  int parent;
  int left;
  int right;
}Node;
    
Node T[10000];
int n, D[10000], H[10000];

int main(){
  int v, l, r, root = 0, i;
  scanf("%d", &n);

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

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

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

  Depth(root, 0);
  Height(root);

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

  return 0;
}

void Depth(int u, int d){
  if(u == -1){
    return;
  }
  D[u] = d;
  Depth(T[u].left, d + 1);
  Depth(T[u].right, d + 1);
}

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

  if(T[u].left != -1){
    h1 = 1 + Height(T[u].left);
  }
  if(T[u].right != -1){
    h2 = 1 + Height(T[u].right);
  }
  return H[u] = (h1 > h2 ? h1 : h2);
}

int Sibling(int u){
  if(T[u].parent == -1){
    return -1;
  }
  if(T[T[u].parent].left != u && T[T[u].parent].left != -1){
    return T[T[u].parent].left;
  }
  if(T[T[u].parent].right != u && T[T[u].parent].right != -1){
    return T[T[u].parent].right;
  }
  return -1;
}

void print(int u){
  int deg = 0;

  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", Sibling(u));

  if(T[u].left != -1){
    ++deg;
  }
  if(T[u].right != -1){
    ++deg;
  }

  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);
  
  if(T[u].parent == -1){   
    printf("root\n");
  }else if(T[u].left == -1 && T[u].right == -1){ 
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}
    
    
       
   
       
    