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

typedef struct node
{
  int degree; 
  int depth; 
  int height; 
  int parent;
  int sibling;
  int left; 
  int right;
} Node;

int cal_depth(Node *,int);
int cal_height(Node *,int);

Node T[30];

int main()
{
  int i,n,v=-1;

  scanf("%d",&n);


  for(i = 0;i < n;i++)
  {
    T[i].depth = 0;
    T[i].height = 0;
    T[i].parent = -1;
    T[i].sibling = -1;
    T[i].left = -1;
    T[i].right = -1;
  }

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

    if(T[v].left != -1)
    {
      T[v].degree ++;
      T[T[v].left].sibling = T[v].right;
    }
    if(T[v].right != -1)
    {
      T[v].degree ++;
      T[T[v].right].sibling = T[v].left;

      T[T[v].left].parent = v;
      T[T[v].right].parent = v;
    }

    for(i = 0;i < n;i++)
    {
      T[i].depth = cal_depth(T,i);
      T[i].height = cal_height(T,i);
    }

    for(i = 0;i < n;i++)
    {
      printf("node %d: parent = %d, sibling = %d, ",i,T[i].parent,T[i].sibling);     
      printf("degree = %d, depth = %d, height = %d, ",T[i].degree,T[i].depth,T[i].height);

      if(T[i].parent == -1) printf("root\n");
      else if((T[i].left == -1) && (T[i].right == -1)) printf("leaf\n");
      else printf("internal node\n");
    }

    return 0;
  }


  int cal_depth(Node *T,int now)
  { 
    if(T[now].parent != -1) return cal_depth(T,T[now].parent) + 1;
    return 0;
  }

  int cal_height(Node *T,int now)
  {
    int sum_right = 0,sum_left = 0;

    if(T[now].left != -1) sum_left = cal_height(T,T[now].left) +1;
    if(T[now].right != -1) sum_right = cal_height(T,T[now].right) +1;

    if(sum_right >= sum_left) return sum_right;
    else return sum_left;
  }