#include<stdio.h>

typedef struct{
  int id;
  int left;
  int right;
  int p;
  int s;
  int deg;
  int dep;
  int h;
}Tree;

int depth(int);
int height(int, int);

Tree data[100];

int main()
{
  int i, n, j, flag, count=0;
  char *str[] = {"root", "internal node", "leaf"};
  Tree temp;
  
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d%d%d", &data[i].id, &data[i].left, &data[i].right);

    if(data[i].left == -1 && data[i].right == -1){
      data[i].deg = 0;
      /* data[i].h = 0; */
    }
    else if(data[i].left == -1 || data[i].right == -1) data[i].deg = 1;
    else data[i].deg = 2;
  }

/* parent判定 */
  for(i = 0; i < n; i++){
    if(data[i].left == -1 && data[i].right == -1) continue;
    for(j = 0; j < n; j++){
      if(j == 0) data[j].p = -1;
      else if(data[j].id == data[i].left || data[j].id == data[i].right) data[j].p = data[i].id;
    }
  }

/* sibling */
  for(i = 0; i < n; i++){
    if(data[i].p == -1) data[i].s = -1;
    if(data[i].left != -1 && data[i].right != -1){
      for(j = 0; j < n; j++){
  	if(data[j].id == data[i].left) data[j].s = data[i].right;
  	else if(data[j].id == data[i].right) data[j].s = data[i].left;
      }
    }
  }

  //height
  for(i = n-1; i >= 0; i--){
    data[i].h = height(data[i].left, data[i].right);
  }

/* 昇順にsort */
  flag = 1;
  j = 0;
  while(flag){
    flag = 0;
    for(i = n-1; i >= 1; i--){
      if(data[i].id < data[i-1].id){
	temp = data[i-1];
	data[i-1] = data[i];
	data[i] = temp;
	flag = 1;
	j++;
      }
    }
  }

  //depth
  for(i = 0; i < n; i++){
    data[i].dep = depth(data[i].p);
  }

  for(i = 0; i < n; i++){
    printf("node %d: ", data[i].id);
    printf("parent = %d, ", data[i].p);
    printf("sibling = %d, ", data[i].s);
    printf("degree = %d, ", data[i].deg);
    printf("depth = %d, ", data[i].dep);
    printf("height = %d, ", data[i].h);
    
    if(data[i].p == -1 && data[i].deg != 0) printf("%s", str[0]);
    else if(data[i].p != -1 && data[i].deg != 0) printf("%s", str[1]);
    else if(data[i].p != -1 && data[i].deg == 0) printf("%s", str[2]);

    printf("\n");
  }
  
  return 0;
}

int depth(int p)
{
  int count=0;

  if(p == -1) return 0;
  else{
    count++;
    return count + depth(data[p].p);
  }
}

int height(int l, int r)
{
  int count=0;

  if(l == -1 && r == -1) return 0;
  else if(l == -1 && r != -1) return data[r].h + count;
  else if(l != -1 && r == -1) return data[l].h + count;

  else if(l != -1 && r != -1){
    count++;
    if(data[l].h == data[r].h) return data[l].h + count;
    else if(data[l].h > data[r].h) return data[l].h + count;
    else if(data[l].h < data[r].h) return data[r].h + count;
  }
}