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

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[N];
int count,x,y;

int depth(int nodeid){
  if(T[nodeid].parent==NIL){
 return 0;
  }
  else{
    count++;
    depth(T[nodeid].parent);
  }
  return count;
}


int degree(int nodeid){
  if(T[nodeid].left==NIL && T[nodeid].right==NIL) return 0;
  else if(T[nodeid].left!=NIL && T[nodeid].right!=NIL) return 2;
  else return 1;
}

int sibling(int nodeid){
  if(T[nodeid].parent==NIL)  return NIL;
  else if(T[T[nodeid].parent].left == nodeid) return T[T[nodeid].parent].right;
  else return T[T[nodeid].parent].left;
}


int height(int nodeid){
  int x=0,y=0;
  if(T[nodeid].left!=NIL){ 
x = height(T[nodeid].left) + 1;
  }

  else if(T[nodeid].right!=-1){
 y = height(T[nodeid].right) + 1;
  }
  if(x < y) return y;
  else return x;

  }

int main(void){
  int i,j,n,k,left,right,newnode,m;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
 T[i].parent = T[i].left = T[i].right =NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&newnode,&m,&k);
    T[m].parent = newnode;
    T[k].parent = newnode;
    T[newnode].left = m;
    T[newnode].right = k;
  }
  for(i=0;i<n;i++){
    count = 0;
    printf("node %d: parent = %d, sibling = %d,degree = %d,depth = %d,height = %d,",i,T[i].parent,sibling(i),degree(i),depth(i),height(i));

    if(T[i].parent == NIL){
      printf(" root\n");
    }
    else if(T[i].left == NIL && T[i].right==NIL){
      printf(" leaf\n");
    }
    else  printf(" internal node\n");
  }
  return 0;
}
  