#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
typedef struct{
  int id;
  int left;
  int right;
  int parent;
  int sibling;
}Node;
 
Node *S;
 
int degree(int);
int depth(int);
int height(int);
 
int d = 0;
 
int main(){
  int i, n, id;
  char s[20];
 
  scanf("%d", &n);
 
  S = malloc(sizeof(Node)*n);
 
  //initialize
  for(i = 0; i < n; i++){
    S[i].parent = -1;
    S[i].sibling = -1;
  }
 
  for(i = 0; i < n; i++){
    scanf("%d", &id);
    S[id].id = id;
 
    scanf("%d%d", &S[id].left, &S[id].right);
    S[S[id].left].parent = id;
    S[S[id].right].parent = id;
    S[S[id].left].sibling = S[id].right;
    S[S[id].right].sibling = S[id].left;
  }
 
  for(i = 0; i < n; i++){
    if(S[i].parent == -1) strcpy(s, "root");
    else if(S[i].left == -1 && S[i].right == -1) strcpy(s, "leaf");
    else strcpy(s,"internal node");
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, S[i].parent, S[i].sibling, degree(i), depth(i), height(i), s);
    d = 0;
  }
  return 0;
}
 
int degree(int i){
  int deg = 0;
 
  if(S[i].left != -1) deg++;
  if(S[i].right != -1) deg++;
  return deg;
}
 
int depth(int i){
  if(S[i].parent == -1) return d;
  else{
    d++;
    return depth(S[i].parent);
  }
}
 
int height(int i){
  int lef = 0, rig = 0;
 
  if(S[i].left != -1){
    lef++;
    lef += height(S[i].left);
  }
 
  if(S[i].right != -1){
    rig++;
    rig += height(S[i].right);
  }
 
  if(rig >= lef) return rig;
  else return lef;
}