#include<stdio.h>

#define N 10000

struct Node{ int r, l, in, t;};
struct Node T[N];

int n,depth[N],height[N];

void getdepth(int);
int getheight(int);

main(){
  int i,d, id, c, l,in;
  
  scanf("%d", &n);
  
  for (i = 0 ; i < n ; i++){
    T[i].r = -1;
    T[i].l = -1;
    T[i].in = -1;
  }

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

  for ( i = 0; i < n; i++ ){
    if(T[i].l != -1){
      T[i].t++;
    }
    if(T[i].in != -1){
      T[i].t++;
    }
  }

  for ( i = 0; i < n; i++ ){
    if(T[i].r == -1){
      depth[i] = 0;
      getdepth(i); 
      break;
    }
  }

  for ( i = 0; i < n; i++ ){
    height[i] = getheight(i); 
  }

  for ( i = 0; i < n; i++ ){
    printf("node %d: parent = %d,", i , T[i].r);

    if(T[i].r == -1)printf(" sibling = -1, ");
    else if(T[T[i].r].in == i)  printf(" sibling = %d, ", T[T[i].r].l);
    else   if(T[T[i].r].l == i) printf(" sibling = %d, ", T[T[i].r].in);

    printf("degree = %d, ", T[i].t);
    printf("depth = %d, height = %d, ", depth[i] , height[i]);

    if(T[i].r == -1) printf("root\n");
    else if(T[i].t == 0) printf("leaf\n");
    else printf("internal node\n");
  }
  
  return 0;
}

void getdepth(int u){
  if(T[u].in != -1){
    depth[T[u].in] = depth[u]+1;
    getdepth(T[u].in);
  }
  if(T[u].l != -1){ 
    depth[T[u].l] = depth[u]+1;
    getdepth(T[u].l);
  }
}

int getheight(int u){
  int tmp,sum;
  if(T[u].in == -1 && T[u].l == -1) return 0;
  if(T[u].l != -1){
    tmp = getheight(T[u].l)+1;
  }
  if(T[u].in != -1){
    sum = getheight(T[u].in)+1;
  }
  if(tmp > sum) return tmp;
  else return sum;
}