#include<stdio.h>

#define N 10000
#define NIL -1
int sibling(int);
int degree(int);
int depth(int);
struct Node{
  int parent;
  int left;
  int right;
};
struct Node T[N];
int D[N];
int depth(int x){
  int sum = 0;
  while(T[x].parent != NIL){
    sum++;
    x = T[x].parent;
  }
  return sum;
}
int sibling(int x){
  if(T[x].parent == NIL) return NIL;
  if(T[T[x].parent].right == x) return T[T[x].parent].left;
  if(T[T[x].parent].left == x) return T[T[x].parent].right;
}
int degree(int x){
  int sum = 0;
  if(T[x].left != NIL) sum++;
  if(T[x].right != NIL) sum++;
  return sum;
}
int height(int x){
  int height1 = 0;
  int height2 = 0;
  if(T[x].left != NIL) height1 = height(T[x].left) + 1;
  if(T[x].right != NIL) height2 = height(T[x].right) + 1;
  if(height1 < height2) return height2;
  else return height1;
}
int main(){
  int v,d,c,s;
  int n;
  int i,j,m;
  scanf("%d",&n);
  for(i=0; i < n; i++){
    T[i].parent = T[i].left = T[i].right = NIL;
  }
  for(j = 0; j < n; j++){
    scanf("%d",&v);
    scanf("%d %d",&T[v].left,&T[v].right);
    T[T[v].left].parent = v;
    T[T[v].right].parent = v;
  }
  for(i = 0; i < n; i++){
    D[i] = depth(i);
  }
  for(m = 0; m<n; m++){
    printf("node %d: parentarent = %d, sibling = %d, degree = %d, deparentth = %d, height = %d, ",m,T[m].parent, sibling(m), degree(m),D[m],height(m));
    if(T[m].parent == NIL) printf("root\n");
    else if(T[m].left != NIL || T[m].right != NIL)printf("internal node\n");
    else printf("leaf\n");
  }
  return 0;
}