#include <stdio.h>
int N;
int sib[100001];
int deg[100001];
int par[100001];


int Depth(int);
int Height(int);

int main() {
  int j,i;
  
  scanf("%d", &N);

  for(i = 0; i < N; ++i) {
    par[i] = -1;
    sib[i] = -1;
    deg[i] = 0;
  }

  for(i = 0; i < N; i++) {
    int id, l, r;

    scanf("%d %d %d", &id, &l, &r);

    if(l != -1) {
      par[l] = id;
      sib[l] = r;
      deg[id]++;
    }

    if(r != -1) {
      par[r] = id;
      sib[r] = l;
      deg[id]++;
    }
  }
  
  for(i = 0; i < N; ++i) {
    int depth = Depth(i);

    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
           i, par[i], sib[i], deg[i], depth, Height(i));
    if(depth == 0) {
      printf("root\n");
    } else if(deg[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
  return 0;
}

int Depth(int i) {
  if(par[i] == -1) return 0;
  return Depth(par[i]) + 1;
}

int Height(int i) {
  int j, h=0;
  
  for(j = 0; j < N; ++j) {
    if(par[j] == i) {
      int tmp = Height(j) + 1;
      if(tmp > h) h = tmp;
    }
  }
  return h;
}



