#include <stdio.h>
#define MAX 100000

typedef struct{
  int p,left,right;
}Node;

Node Tree[MAX];
int n,height;
int Depth[MAX];



int getDepth(int i){
  int depth=0;
  while(Tree[i].p>=0){
    i=Tree[i].p;
    depth++;
  }
  return depth;
}



main(){
  int i,ii,j,n;
  int  id,k,np,right,left;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    Tree[i].p=-1;
    Tree[i].left=-1;
    Tree[i].right=-1;
  }


  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&np);
      Tree[np].p=id;
      
      if(j==0)
	Tree[id].left=np;
      else if (j>=1)
	Tree[right].right=np;
      right=np;
    }
  }



  for(i=0;i<n;i++)
    Depth[i]=getDepth(i);
  
  
  for(i=0;i<n;i++){
    if(Tree[i].p==-1)
      printf("node %d: parent = %d, depth = %d, root, ",i,Tree[i].p,Depth[i]);
    else if(Tree[i].left==-1)
      printf("node %d: parent = %d, depth = %d, leaf, ",i,Tree[i].p,Depth[i]);
    else
      printf("node %d: parent = %d, depth = %d, internal node, ",i,Tree[i].p,Depth[i]);
    

    ii=i;

    printf("[");
    if(Tree[ii].left!=-1){
      printf("%d",Tree[ii].left);
      if(Tree[Tree[ii].left].right==-1) printf("]\n");
      else printf(",");
      
      ii=Tree[ii].left;
      
      
      while(Tree[ii].right!=-1){
	printf(" %d",Tree[ii].right);
	
	if(Tree[Tree[ii].right].right==-1)
	  printf("]\n");
	else printf(",");
	ii =Tree[ii].right;
      }
    }
    else  printf("]\n");
  }
    
    
  return 0;
}