#include<stdio.h>
 
#define MAX 100000
 
 
 
typedef struct{
  int parent;
  int left;
  int right;
  int degree;
}node;
 
int getdepth(int);
int getsibling(int);
int getheight(int);
 
node ki[MAX];
 
int main(){
  int i, kazu, n, depth;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++) ki[i].parent = ki[i].left = ki[i].right = -1;
 
  for(i=0 ; i<n ; i++){
    scanf("%d",&kazu);
    scanf("%d%d",&ki[id].left,&ki[id].right);
    if(ki[id].left != -1){
      ki[ki[kazu].left].parent = kazu;
      ki[kazu].degree++;
    }
    if(ki[kazu].right != -1){
      ki[ki[kazu].right].parent = kazu;
      ki[kazu].degree++;
    }

  }
 
  for(i=0 ; i<n ; i++){
 
    depth = getdepth(i);
    if(depth==0) printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n", i, ki[i].parent, getsibling(i), ki[i].degree, depth, getheight(i));
 
    else if(ki[i].left==-1 && ki[i].right==-1) printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n", i, ki[i].parent, getsibling(i), ki[i].degree, depth, getheight(i));
 
    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n", i, ki[i].parent, getsibling(i), ki[i].degree, depth, getheight(i));
  }
  return 0;
}
 
int getdepth(int i){
  int kazu = ki[i].parent;
  int sum = 0;
 
  while(kazu != -1){
    kazu = ki[kazu].parent;
    sum++;
  }
  return sum;
}
 
int getsibling(int i){
  if(ki[i].parent == -1) return -1;
  else if(ki[ki[i].parent].left == i) return ki[ki[i].parent].right;
  else return ki[ki[i].parent].left;
}
 
int getheight(int i){
  int l, r;
  if(i==-1) return -1;
 
  l = getheight(ki[i].left);
  r = getheight(ki[i].right);
 
  if(l>r) return l+1;
  else return r+1;
 
}