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

typedef struct node {
  int value; /* このノードが保持する値 */
  int depth; /* 深さ */
  struct node *parent; /* 親の値 */
  struct node *sibling; /* 兄弟 */
  struct node *left; /* 左側の子ノード */
  struct node *right; /* 右側の子ノード */
} node_t;

node_t tree[100003];

int main()
{
  int n,i,l,r,now,degree = 2,max_depth,height;

  scanf("%d",&n);

  /* 初期化 */
  for(i = 0;i < n;i++){
    tree[i].value = -1;
    tree[i].parent = NULL;
    tree[i].sibling = NULL;
    tree[i].depth = 0;
    tree[i].left = NULL;
    tree[i].right = NULL;
  }

    for(i = 0;i < n;i++){

    scanf("%d",&now);
    tree[now].value = now;
    scanf("%d %d",&l,&r);
    tree[now].left = &tree[l];
    if(l != -1) tree[l].depth += 1;
    tree[now].right = &tree[r];
    if(r != -1) tree[r].depth += 1;
    tree[now].left->sibling = &tree[r];
    tree[now].right->sibling = &tree[l];
    tree[now].right->parent = &tree[now];
    tree[now].left->parent = &tree[now];
    }
   
  max_depth = tree[0].depth;
  for(i = 1;i < n;i++){
    if(max_depth < tree[i].depth) max_depth = tree[i].depth;
    }

  /* 出力 */
  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, sibling = %d, ",tree[i].value,tree[i].parent->value,tree[i].sibling->value); 
    if(tree[i].left->value == -1) degree--;
    if(tree[i].right->value == -1) degree--;
    if(tree[i].left->value != -1)  height = tree[i].left->depth - tree[i].depth;
    printf("degree = %d, depth = %d, height = %d, ",degree,tree[i].depth,height);
    if(tree[i].parent->value == -1) printf("root\n");
    else if(tree[i].left->value == -1) printf("leaf\n");
    else printf("internal node\n");
  }

  return 0;
}

    
      