#include<stdio.h>

#define NIL -1

typedef struct{
  int parent,left,right;
}node;

void getdepth(int,int);
void printchildren(int);
int getheigtht(int);
int getsibling(int);

node T[30];
int D[30];
int H[30];

int main(){
  int i,j,d,v,c,l,r,n;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent = T[i].left = T[i].right = D[i] = NIL;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != NIL)T[l].parent = v;
    if(r != NIL)T[r].parent = v;
  }

  for(i=0;i<n;i++){
    if(T[i].parent == NIL)r = i;
  }
  
  getdepth(r,0);
  getheight(r);
  
  for(i=0;i<n;i++)printchildren(i);

  return 0;
}

void getdepth(int u,int p){
  D[u] = p;
  if(T[u].right != NIL)getdepth(T[u].right,p+1);
  if(T[u].left != NIL)getdepth(T[u].left,p+1);
}

int getheight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].left!=NIL)h1 = getheight(T[u].left)+1;
  if(T[u].right!=NIL)h2 = getheight(T[u].right)+1; 
  if(h1 >= h2)H[u]=h1;
  else H[u]=h2;
  return H[u];
}

int getsibling(int u){
  
  if(u != T[T[u].parent].right && T[T[u].parent].right != NIL)return T[T[u].parent].right;
  else if(u != T[T[u].parent].left && T[T[u].parent].left != NIL)return T[T[u].parent].left;
  else return NIL;
  
}

void printchildren(int u){
  int i;
  int c = T[u].left;

  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);

  printf("sibling = %d, ",getsibling(u));
  
  if(T[u].left==NIL&&T[u].right==NIL)printf("degree = 0, ");
  else if(T[u].left!=NIL&&T[u].right!=NIL)printf("degree = 2, ");
  else printf("dgree = 1, ");

  printf("depth = %d, ",D[u]);
  
  printf("height = %d, ",H[u]);
    
  if(T[u].parent == NIL)printf("root\n");
  else if(T[u].left == NIL)printf("leaf\n");
  else printf("internal node\n");
    
}