include <stdio.h>

typedef struct{
  int id;
  int parent;
  int depth;
  int k;
  int child[100000];
} node;

node tree[100000];


int main(){

  int n,i,j,count,k,m;
  scanf("%d",&n);

 for(i=0;i<n;i++){
   tree[i].parent = -1;
   tree[i].depth = 0;
 }
 
 for(i=0;i<n;i++){
   scanf("%d",&m);
   tree[m].id = m;
   scanf("%d",&tree[m].k);
   for(j=0;j<tree[m].k;j++){
     scanf("%d",&tree[m].child[j]);
     tree[tree[m].child[j]].parent = tree[m].id;
   }
 }

 for(i=0;i<n;i++){
   j=i;
   count = 0;
   while(tree[j].parent != -1){
     j = tree[j].parent;
     count++;
   }
   tree[i].depth = count;
 }

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