#include<stdio.h>
int N;
int parents[100000];
int si[100000];
int de[100000];
  
int Dep(int i) {
  if(parents[i] == -1) return 0;
  return Dep(parents[i]) + 1;
}
   
int Hei(int i) {
  int j, x, y;
  
  x = 0;
  
  for(j = 0; j < N; j++) {
    if(parents[j] == i) {
      y = Hei(j) + 1;
      if(y > x) x = y;
    }
  }
  
  return x;
}
  
int main() {
  int i, j, depth;
  int id, left, right;
  
  scanf("%d", &N);
  for(i = 0; i < N; i++) {
    parents[i] = -1;
    si[i] = -1;
    de[i] = 0;
  }
  for(i = 0; i < N; i++) {
    scanf("%d %d %d", &id, &left, &right);
  
    if(left != -1) {
      parents[left] = id;
      si[left] = right;
      de[id]++;
    }
  
    if(right != -1) {
      parents[right] = id;
      si[right] = left;
      de[id]++;
    }
  }
    
  for(i = 0; i < N; i++) {
  
    printf("node %d: parents = %d, si = %d, de = %d, depth = %d, height = %d, ", i, parents[i], si[i], de[i], Dep(i), Hei(i));
  
    if(depth == 0) {
      printf("root\n");
    }
  
    else if(de[i] == 0) {
      printf("leaf\n");
    }
  
    else {
      printf("internal node\n");
    }
  }
  
  return 0;
}