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

typedef struct d{
  int p;    // parent
  int s;    // sibling
  int deg;  // degree
  int dep;  // depth
  int h;    // height
  int left;
  int right;
}data;

data *tree;

void dataprinter(data out){
  puts("-----data-----");
  printf("p=%d s=%d deg=%d dep=%d h=%d left=%d right=%d\n"
  ,out.p, out.s, out.deg, out.dep, out.h, out.left, out.right);
  puts("=====data=====");
}

void init(int n){
  int i;
  tree = (data *)malloc(sizeof(data) * n);
  for(i=0; i<n; i++){
    tree[i].p = -1;
    tree[i].s = -1;
    tree[i].deg = 0;
    tree[i].dep = 0;
    tree[i].h = 0;
    tree[i].left = -1;
    tree[i].right = -1;
  }
}

void maketree(void){
  int id;

  scanf("%d ",&id);
  scanf("%d %d ",&tree[id].left, &tree[id].right);
  if(tree[id].left != -1){
    tree[tree[id].left].p = id;
    tree[tree[id].left].s = tree[id].right;
    tree[id].deg += 1;
  }
  if(tree[id].right != -1){
    tree[tree[id].right].p = id;
    tree[tree[id].right].s = tree[id].left;
    tree[id].deg += 1;
  }
}

int isParent(int i){
  if(tree[i].p == -1) return 0;
  else return (isParent(tree[i].p)) + 1;
}

int isChildren(int i, int call){
  int left=0, right=0;
  // printf("isChildren(%d, %d)\n",i, call);
  if(tree[i].deg == 0) {
    // puts("deg == 0");
    // puts("return 0");
    return 0;
  }

  left = isChildren(tree[i].left, call+1);
  right = isChildren(tree[i].right, call+1);


  if(left < right){
  // printf("return %d\n",left+1);
  return right + 1;
  }
  // printf("return %d\n",right+1);
  return left + 1;

}

void printer(int n){
  int i;

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d "
    , i, tree[i].p, tree[i].s, tree[i].deg, tree[i].dep, tree[i].h);
    if(tree[i].p == -1){
      puts("root");
    }
    else if(tree[i].deg == 0){
      puts("leaf");
    }
    else{
      puts("internal node");
    }
  }
}

int main(){
  int i, n;

  scanf("%d",&n);
  init(n);
  for(i=0; i<n; i++){
    maketree();
  }
  for(i=0; i<n; i++){
    tree[i].dep = isParent(i);
    // printf("------isChildren(%d, 0)-----\n",i);
    tree[i].h = isChildren(i, 0);
  }

  printer(n);

  return 0;
}

