#include <stdio.h>
#define N 25
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
}node;
node T[N];

void Height(int);

int main(){
  int i,j,id,left,right,n,h,max;
  int deg[N],dep[N],s[N],hei[N]; 

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
    s[i] = NIL;
    deg[i] = 0;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d%d%d",&id,&left,&right);

    if(left != NIL){
      T[left].p = id;
      deg[id]++;
    }

    if(right != NIL){
      T[right].p = id;
      deg[id]++;
    }
    T[id].l = left;
    T[id].r = right;
    s[left] = right;
    s[right] = left;
  }

  for(i = 0; i < n; i++){
    dep[i] = hei[i] = 0;
    j = i;
    while(T[j].p != NIL){
      j = T[j].p;
      dep[i]++;
    }
    max = h = 0;
    Height(i);
    hei[i] = max;
  }


  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,T[i].p,s[i],deg[i],dep[i],hei[i]);

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

void Height(int n){
  int height,m;
  
  if(T[n].l == NIL || T[n].r == NIL) m = height;
  if(T[n].l != NIL){
    height++;
    Height(T[n].l);
  }
  if(T[n].r != NIL){
    height++;
    Height(T[n].r);
  }
  height -= 1;
}