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

#define N 100000

typedef enum{root, intnode, leaf}type;

typedef struct tree_tag{
  struct tree_tag** child;
  int Id;
  int depth;
  int parent;
  int num;
  type t;
} tree;


tree treelist[N];
int idlist[N];
void which(type t){

 switch(t){
  case root:
   printf("root, ");
   break;
  case intnode:
   printf("internal node, ");
   break;
  case leaf:
   printf("leaf, ");
   break;
 }



}
int main(){
int n, cid, id, j, k, count = 0;

  scanf("%d", &n);
 for(count; count < N; count++)
   treelist[count].parent = -1;

 for(count = 0; count < n; count++){
   scanf("%d", &id);
   scanf("%d", &k);
   idlist[count] = id;
   treelist[id].num = k;
   treelist[id].Id = id;
   if(k != 0)
   treelist[id].child = malloc(4*k);

   for(j = 0; j < k; j++){
     scanf("%d", &cid);
     treelist[id].child[j] = &treelist[cid];
     treelist[cid].depth = treelist[id].depth + 1;
     treelist[cid].parent = id;
     if(treelist[cid].t != leaf){
       treelist[cid].t = intnode;
     }
   }
   if(k == 0 && n > 1){
     treelist[id].t = leaf;
   }

 }

 for(count = 0; count < n; count++){

    printf("node %d: parent = %d, depth = %d, ", idlist[count], treelist[idlist[count]].parent, treelist[idlist[count]].depth);
    which(treelist[idlist[count]].t);
    printf("[");
    for(j = 0; j < treelist[idlist[count]].num; j++){
     printf("%d", treelist[idlist[count]].child[j]->Id);
      if(j != treelist[idlist[count]].num - 1){
         printf(", ");
      }
    }

    printf("]");
   printf("\n");
 }


 return 0;
}