#include<stdio.h>
#define NIL -1;

typedef struct{
  int p;
  int left;
  int right;
}tree;

tree T[100001];
  int n; //接点の個数

int main(){
  int i,j;
  int id; //接点の番号
  int left,right; //左,右の子
  int s[10001],d[10001];
  
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    d[i]=0;
    T[i].p=NIL;
    T[i].left=NIL;
    T[i].right=NIL;
    s[i]=NIL;
  }
  
  for(i=0 ; i<n ;i++){
    scanf("%d %d% d",&id,&left,&right);
    if(left!=NIL && right!=NIL){
      d[id] = 2;
      T[id].left = left;
      T[id].right = right;
      T[left].p = id;
      T[right].p = id;
      s[left] = right;
      s[right] = left;
    }
    else if(left!=NIL && right==NIL){
      d[id] = 1; 
      T[id].left = left;
      T[left].p = id;
    }
    else if(left==NIL && right!=NIL){
      d[id] = 1; 
      T[id].right = right;
      T[right].p = id;
    }
    else d[id] = 0;
  }

  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],d[i],calcDepth(i),calcHeight(i));
    if(T[i].p==NIL) printf("root\n"); 
    else if(T[i].left==NIL && T[i].right==NIL) printf("leaf\n");
    else printf("internal node\n");
  }
  return 0;
}

int calcDepth(int id){
  if(T[id].p==NIL) return 0;
  return calcDepth(T[id].p)+1;
}
 
int calcHeight(int id){
  int i,c,q=0;
  for(i=0 ; i<n ; i++){
    if(T[i].p==id){
      c=1+calcHeight(i);
      if(q<c) q=c;
    }
  }
    return q;
}