#include<stdio.h>
 
int depth(int);
void P(int);
 
struct NODE{
  int p,l,r;
};
 
struct NODE tree[100005];
int n,D[100005];
 
main(void){
 
  int i,j,d,e,c,l,r;
    
  scanf("%d",&n);
    
  for (i=0;i<n;i++){
    tree[i].p=tree[i].l=tree[i].r=-1;
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&e);
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      tree[c].p=e;
        
      if(j==0){
    tree[e].l=c;
      }
       
      else if(j>=1){
    tree[r].r=c;
      }
      r=c;
       
    }
   }
    
  for(i=0;i<n;i++){
    D[i]=depth(i);
  }
  
  for(i=0;i<n;i++){
    P(i);
  }
  return 0;
}
 
int depth(int a){
 
  int d=0;
  
  while(tree[a].p>=0){
    a=tree[a].p;
    d=d+1;
  }
  return d;
}
void P(int b){
  if(tree[b].p==-1){
    printf("node %d: parent = %d, depth = %d, root, ",b,tree[b].p,D[b]);
  }
    
  else if(tree[b].l==-1){
    printf("node %d: parent = %d, depth = %d, leaf, ",b,tree[b].p,D[b]);
  }
    
  else printf("node %d: parent = %d, depth = %d, internal node, ",b,tree[b].p,D[b]);
    
  printf("[");
  int t;
  t = b;
  if(tree[t].l!=-1){
    printf("%d",tree[t].l);
    if(tree[tree[t].l].r==-1){
      printf("]\n");
    }
    else printf(",");
    t =tree[t].l;
    while(tree[t].r!=-1){
      printf(" %d",tree[t].r);
      if(tree[tree[t].r].r==-1){
    printf("]\n");
      }
      else printf(",");
      t=tree[t].r;
    }
  }
  else printf("]\n");
}