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

#define N 32

typedef struct {
  int parent;
  int child;
  int sibling;
  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].child; child != -1; child = array[child].sibling)
    dfs(array, child, d+1);

  // calculate height
  left = array[id].child;
  if (left == -1)
    array[id].height = 0;
  else {
    right = array[left].sibling;
    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;
  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].child = left;
    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++) {
    // determination a node type
    if (array[i].parent == -1)
      type = "root";
    else if (array[i].child == -1)
      type = "leaf";
    else
      type = "internal node";
    
    // calculate degree
    if (array[i].child == -1)
      degree = 0;
    else if(array[array[i].child].sibling == -1)
      degree = 1;
    else
      degree = 2;
    
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n"
  	   , i, array[i].parent, array[i].sibling,
	   degree, array[i].depth, array[i].height, type);
  }

  return 0;
}