#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[MAX];

int n;
int Depth[MAX], Height[MAX];

int GetDepth(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NIL ) break;
    d++;
  }
  return d;
}

int GetS(int u){
  if ( T[u].p == NIL ) return NIL;
  if ( T[T[u].p].l != u && T[T[u].p].l != NIL ) return T[T[u].p].l;
  if ( T[T[u].p].r != u && T[T[u].p].r != NIL ) return T[T[u].p].r;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", GetS(u));

  int deg = 0;
  
  if ( T[u].l != NIL ) deg++;
  if ( T[u].r != NIL ) deg++;
  
  printf("degree = %d, ", deg);
  printf("depth = %d, ", Depth[u]);
  printf("height = %d, ", Height[u]);

  if ( T[u].p == NIL ){
    printf("root\n");
  }
  else if ( T[u].l == NIL && T[u].r == NIL ){
    printf("leaf\n");
  }
  else {
    printf("internal node\n");
  }
}

int main(){
  int i, v, l, r;
  
  scanf("%d", &n);

  for ( i = 0; i < n; i++ )
    T[i].p = NIL;

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    
    T[v].l = l;
    T[v].r = r;

    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ){
    Depth[i] = GetDepth(i);
    Height[i] = 0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) {
      Height[i] = 0;
      p = T[i].p;
      c = 1;

      while(1){
	if ( p == NIL ) break;
	if ( Height[p] < c ) Height[p] = c;
	c++;
	p = T[p].p;
      }
    }
  }

  for ( i = 0; i < n; i++ ) print(i);
  
  return 0;
}

