#include <stdio.h>
#include <string.h>

#define N 32

typedef struct {
  int parent;
  int left;
  int right;
  int depth;
  int height;
} node_t;

void dfs(node_t *array, int id, int d) {
  int child, left, right;

  if (id == -1)
    return;
  array[id].depth = d;
  /* for (child = array[id].left; child != -1; child = array[id].right) */
  /*   dfs(array, child, d+1); */
  if (array[id].left != -1)
    dfs(array, array[id].left, d+1);
  if (array[id].right != -1)
    dfs(array, array[id].right, d+1);

  // calculate height
  left = array[id].left;
  if (left == -1)
    array[id].height = 0;
  else {
    right = array[id].right;
    if (right == -1)
      array[id].height = array[left].height + 1;
    else {
      if (array[right].height < array[left].height)
	array[id].height = array[left].height + 1;
      else
	array[id].height = array[right].height + 1;
    }
  }
}

int main(void) {
  int i, n, pid, left, right, degree, parent, sibling;
  char *type;
  node_t array[N];
  memset(array, -1, sizeof(array));

  // input
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &pid);
    scanf("%d %d", &left, &right);
    if (left != -1)
      array[left].parent = pid;
    if (right != -1)
      array[right].parent = pid;
    array[pid].left = left;
    array[pid].right = right;
    /* if (left != -1) */
    /*   array[left].sibling = right; */
  }

  // calculate depth
  for (i = 0; i < n; i++) {
    if (array[i].parent == -1) {
      dfs(array, i, 0);
      break;
    }
  }

  // output
  /* for (i = 0; i < n; i++) { */
  /*   // sibling's sibling is me */
  /*   if (array[i].sibling != -1) */
  /*     array[array[i].sibling].sibling = i; */
  /* } */

  for (i = 0; i < n; i++) {
    parent = array[i].parent;

    // determination a node type
    if (parent == -1)
      type = "root";
    else if (array[i].left == -1)
      type = "leaf";
    else
      type = "internal node";
    
    // calculate degree
    if (array[i].left == -1 && array[i].right == -1)
      degree = 0;
    else if(array[i].left == -1 && array[i].right != -1)
      degree = 1;
    else if(array[i].left != -1 && array[i].right == -1)
      degree = 1;
    else
      degree = 2;

    // determination a sibling node
    if (i == array[parent].right)
      sibling = array[parent].left;
    else if (i == array[parent].left)
      sibling = array[parent].right;
    else
      sibling = -1;
    
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, parent, sibling, degree, array[i].depth, array[i].height, type);
  }

  return 0;
}