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

#define N 100000
#define NIL -1

typedef struct t{
  int id;
  int childnum;
  int parent;
  int depth;
  unsigned int *child;
}Tree;

int main(){
  Tree T[N];
  int treenum, i, id, j;
  scanf("%d", &treenum);
  
  for(i = 0; i < treenum; i++){
    T[i].parent = NIL;
    T[i].depth = 0;
  }
  
  for(i = 0; i < treenum; i++){
    scanf("%d", &id);
    T[id].id = id;
    scanf("%d", &T[id].childnum);

    T[id].child = malloc(sizeof(int) * T[id].childnum);
    for(j = 0; j < T[id].childnum; j++){
      scanf("%d", &T[id].child[j]);
      T[ T[id].child[j] ].parent = id;
      T[ T[id].child[j] ].depth = T[id].depth+1;
    }
  }
  
  for(i = 0; i < treenum; i++){
    printf("node %d:, parent = %d, depth = %d, ", T[i].id, T[i].parent, T[i].depth);

    if(T[i].parent == -1){
      printf("root, ");
    }
    else if(T[i].childnum == 0){
      printf("leaf, ");
    }
    else{
      printf("internal node, ");
    }
    
    printf("[");
    for(j = 0; j < T[i].childnum-1; j++){
      printf("%d, ", T[i].child[j]);
    }
    if(T[i].childnum != 0){
      printf("%d", T[i].child[j]);
    }
    printf("]\n");
    
  }
  
  return 0;
}

