#include <stdio.h>
#include <stdlib.h>
#define N 10000
 
typedef struct{
  int id;
  int p;
  int s;
  int c;
  int child[2];
} Tree;
 
int n;
Tree *T;
 
int getdepth(int u){
 
  int d = 0;
 
  while(T[u].p >= 0){
    u = T[u].p;
    d++;
  }
  return d;
}

int getheight(int x, int y){
  int a=0, b=0;
   
  if(T[x].child[1] != -1){
    a = getheight(T[x].child[1], y+1);
  }  
  if(T[x].child[0] != -1){
    b = getheight(T[x].child[0], y+1);
  } 
  if(T[x].child[0] == -1 && T[x].child[1] == -1){
    return y;
  }
  if(a>=b){
    return a;
  }
  else return b;
}
 
void print(void){
 
  int i,j,flag=0;
 
  for(i=0;i<n;i++){
    flag=0;
 
    printf("node %d: parent = %d, sibling = %d, degree = %d, ",T[i].id,T[i].p,T[i].s,T[i].c);

    printf("depth = %d, height = %d, ",getdepth(i),getheight(i,0));

    if(T[i].c == 0 && T[i].p != -1)
      printf("leaf");
    else if(T[i].c != 0 && T[i].p != -1)
      printf("internal node");
    else
      printf("root");
    printf("\n");
  }
}
 
 
int main(void){
 
  int i,j,node,deg;
 
  scanf("%d",&n);
 
  T = malloc(n * sizeof(Tree));
 
  for(i=0;i<n;i++){
    T[i].id = T[i].p = T[i].s = T[i].child[0] = T[i].child[1] = -1;
    T[i].c = 0;
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&node);
    scanf("%d %d",&T[node].child[0],&T[node].child[1]);
    T[node].id = node;
    T[T[node].child[0]].p = node;
    T[T[node].child[1]].p = node;
    T[T[node].child[0]].s = T[node].child[1];
    T[T[node].child[1]].s = T[node].child[0];
    if(T[node].child[0] != -1){
      T[node].c = 2;
    }
  }
  print();
  free(T);
  return 0; 