#include <stdio.h>
#define N 100000
#define NIL -1

typedef struct node{
  int parent;
  int left;
  int right;
}Node;

Node T[N];

int n;

int Calc_depth(int x){
  if(T[x].parent == NIL) return 0;
  return Calc_depth(T[x].parent) + 1;
}

void type_pri(int y){
  if(T[y].parent == - 1) printf("root, ");
  else if(T[y].left == NIL) printf("leaf, ");
  else printf("internal node, ");
}

void print_chil(int z){
  int tmp;
  printf("[");
  tmp = T[z].left;
  while(tmp != NIL){
    printf("%d",tmp);
    if(T[tmp].right != NIL) printf(", ");
    tmp = T[tmp].right;
  }
  printf("]");
}

void print(void){
  int i;
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,Calc_depth(i));
    type_pri(i);
    print_chil(i);
    printf("\n");
  }
}

int main()
{
  int i,id,k,j,num,root,l;
  scanf("%d",&n);
  for(i = 0; i < n;i++){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
  for(i = 0; i < n;i++){
    scanf("%d%d",&id,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&num);
      if(j == 0) T[id].left = num;
      else T[l].right = num;
      l = num;
      T[num].parent = id;
    }
  }
  for(i = 0; i < n; i++){
    if(T[i].parent == NIL) root = i;
  }
  print();
  return 0;    
}

