#include<stdio.h>
#include<stdlib.h>
#define NIL -1

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

node *tree;

int searchHeight(int x){
  int lh=0, rh=0, res=0;
  //printf("ここまできたよ！\n");
  if(tree[x].right == -1 && tree[x].left == -1) return 0;
  
  lh = searchHeight(tree[x].left)+1;
  rh = searchHeight(tree[x].right)+1;

  //printf("ここまできたよ？\n");
  if(lh > rh) return lh;
  else return rh;
}

int main(){
  int i, j, n;
  int num;

  scanf("%d", &n);
  tree = (node*)malloc(sizeof(node)*n);
  for(i=0; i<n; i++){ //初期化
    tree[i].parent = tree[i].right = tree[i].left = NIL;
    tree[i].depth = 0;
    tree[i].degree = 0;
    tree[i].sib = NIL;
    tree[i].height = 0;
  }

  for(i=0; i<n; i++){
    scanf("%d", &num);
    scanf("%d%d", &tree[num].left, &tree[num].right);
    if(tree[num].left != NIL){
      tree[num].degree++;
      tree[tree[num].left].parent = num;
      tree[tree[num].left].depth = tree[num].depth + 1;
    }
    if(tree[num].right != NIL){
      tree[num].degree++;
      tree[tree[num].right].parent = num;
      tree[tree[num].right].depth = tree[num].depth + 1;
    }
    if(tree[num].left == NIL && tree[num].right == NIL){
      tree[num].depth = tree[tree[num].parent].depth + 1;
    }
    // 怪しす
    if(tree[num].degree == 2){
      tree[tree[num].right].sib = tree[num].left;
      tree[tree[num].left].sib = tree[num].right;
    }
    
  }

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
	   i, tree[i].parent, tree[i].sib, tree[i].degree, tree[i].depth, searchHeight(i));
    if(tree[i].depth == 0) printf("root\n");
    else if(tree[i].degree == 0) printf("leaf\n");
    else printf("internal node\n");
  }

  return 0;
}

