#include<stdio.h>
#include<stdlib.h>

typedef struct node{
  int id;
  int l;
  int r;
  int p;
  int deg;
  int dep;
  int s;
  int h;
  char type;
}T;

int main()
{
  int i,j,n,n_id,maxdep=0;

  scanf("%d",&n);

  T x[n];

  for(i=0; i<n; i++){
    x[i].dep = 0;
    x[i].h = 0;
    x[i].p = -1;
  }

  for(i=0; i<n; i++){
    scanf("%d",&n_id);
    scanf("%d%d",&x[n_id].l,&x[n_id].r);
    x[n_id].id = n_id;
    if(x[n_id].l == -1 && x[n_id].r == -1){
      x[n_id].type = 'l';
      x[n_id].deg = 0;
      x[n_id].h = 0;
      if(x[n_id].p != -1){
	x[x[n_id].p].h = x[n_id].h+1;
	x[n_id].dep = x[x[n_id].p].dep + 1;
      }
      
      continue;
    }
      else if(x[n_id].l == -1){
      x[x[n_id].r].p = x[n_id].id;
      x[x[n_id].r].s = -1;
      x[n_id].deg = 1;
      x[x[n_id].r].type = 'i';
      x[x[n_id].r].dep = x[n_id].dep + 1;
    }
    else if(x[n_id].r == -1){
      x[x[n_id].l].p = x[n_id].id;
      x[x[n_id].l].s = -1;
      x[n_id].deg = 1;
      x[n_id].type = 'i';
      x[x[n_id].l].dep = x[n_id].dep + 1;
    }
    else {
      x[x[n_id].r].p = x[n_id].id;
      x[x[n_id].r].s = x[n_id].l;
      x[n_id].deg = 2;
      x[n_id].type = 'i';
      x[x[n_id].r].dep = x[n_id].dep + 1;
      x[x[n_id].l].p = x[n_id].id;
      x[x[n_id].l].s = x[n_id].r;
      x[x[n_id].l].dep = x[n_id].dep + 1;
    }
    x[n_id].h++;
    x[x[n_id].p].h = x[n_id].h+1;
  }

  for(i=0; i<n; i++){
    if(x[i].dep >= maxdep)
      maxdep = x[i].dep;
  }

  for(i=0; i<n; i++){
    if(x[i].p == -1){
      x[i].type = 'r';
      x[i].s = -1;
      x[i].h = maxdep;
    }

    printf("node %d: parent = %d, sibling = %d, degree = %d, ",
	   x[i].id, x[i].p, x[i].s, x[i].deg);

    printf("depth = %d, height = %d, ",x[i].dep, x[i].h);

    if(x[i].type == 'r')
      printf("root\n");
    else if(x[i].type == 'i')
      printf("internal node\n");
    else
      printf("leaf\n");
  }
  return 0;
}
      
      

