#include<stdio.h>

#define MAX 100005
#define NIL -1

using namespace std;

struct Node_struct{
  int p, s, l, r, d;
  Node_struct(){ s = -1; }
};
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX], H[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", u, T[u].p, T[u].s, T[u].d, D[u], H[u]);

  if(T[u].p == NIL) printf("root");
  else if(T[u].l == NIL && T[u].r == NIL) printf("leaf");
  else printf("internal node");
  printf("\n");
}

void calcHeight(int u, int p){
  if(T[u].l == NIL && T[u].r == NIL){
    H[u] = p;
    if(T[u].p != NIL)calcHeight(T[u].p, p+1);
    return;
  }else{
    if(H[u] < p) H[u] = p;
    if(T[u].p != NIL)calcHeight(T[u].p, p+1);
  }
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l == NIL && T[u].r == NIL)calcHeight(u, 0);
  if(T[u].l != NIL) calcDepth(T[u].l, p+1);
  if(T[u].r != NIL) calcDepth(T[u].r, p+1);
}

int main(){
  int i, j;
  int n;
  int id, left, right, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL, T[i].d = 0;

  for(i=0; i<n; i++){
    scanf("%d %d %d", &id, &left, &right);
    if(left != NIL)T[left].p = id, T[left].s = right,T[id].l = left, T[id].d++;
    if(right != NIL)T[right].p = id, T[right].s = left,T[id].r = right, T[id].d++;
  }
  for(i=0; i<n; i++){
    if(T[i].p == -1) {
      root = i;
      break;
    }
  }
  calcDepth(root, 0);
  for(i=0; i<n; i++) print(i);

  return 0;
}

