#include <stdio.h>

#define N 25
#define NIL -1

typedef struct node{
  int id;        //???????????????
  int left;      //???????????????????????????
  int right;     //???????????????????????????
  int parent;    //???
  int sibling;   //left???????????????????????£????????????????????????
  int depth;     //??????????????±???
  int height;    //??????????????¬??????????????????
  int degree;    //????????????????????°
}Node;

int main()
{

  Node tree[N];
  int n, id, left, right, i, j, p, q, s, t, a;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    tree[i].id = i;
    tree[i].left = NIL;
    tree[i].right = NIL;
    tree[i].sibling = NIL;
    tree[i].parent = NIL;
    tree[i].depth = 0;
    tree[i].height = 0;
    tree[i].degree = 0;
  }

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

    tree[id].left = left;
    tree[id].right = right;
    tree[left].parent = id;
    tree[right].parent = id;
    tree[left].sibling = right;
    tree[right].sibling = left;

    if((left != -1) && (right != -1)) tree[id].degree = 2;

  }

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

    // printf("%d ",tree[i].parent);
      
    // s = i;
    // p = i;

     while(1){                   //??±???????¨????
      t = tree[s].parent;
      if(t == NIL) break;
      s = t;
      tree[i].depth++;
      }
    

    /* while(1){
      q = tree[p].left;           //??????????¨????
      if(q == NIL) break;
      p = q;
      tree[i].height++;
      }*/
  }

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

    printf("node %d: ", i);                            //node?????????
    printf("parent = %d, ", tree[i].parent);           //parent?????????

    printf("sibling = %d, ", tree[i].sibling);         //sibling?????????
   
    printf("degree = %d, ", tree[i].degree);                          //degree?????????

    printf("depth = %d, ", tree[i].depth);             //depth?????????

    //  printf("height = %d, ", tree[i].height);

    if(tree[i].parent == NIL){
      printf("root\n");
    }
    else if((tree[i].left != NIL) || (tree[i].right != NIL)){      //?????????????¨????
      printf("internal node\n");
    }
    else printf("leaf\n");  

  }

  return 0;
}