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

int Depth(int**,int*,int,int);

int main(){
  int n,i,j,**tree,*node,kazu,ban,oya[100001];

  scanf("%d",&n);
  tree=(int **)malloc(n*sizeof(int *));
  for(i=0;i<100001;i++) oya[i]=-1;   /* 初期化 */

  for(i=0;i<n;i++){
    scanf("%d%d",&ban,&kazu);
    

    node=(int *)malloc((kazu+2)*sizeof(int));
    node[0]=ban;
    node[1]=kazu;

    for(j=0;j<kazu;j++){
      scanf("%d",&node[j+2]);
      
      oya[node[j+2]]=node[0];
    }

    tree[ban]=node;
  }


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

    printf("node %d: parent = %d, depth = %d, ",i,oya[i],Depth(tree,oya,0,i) );
    
    if(oya[tree[i][0]]==-1){
      printf("root, [");
      for(j=0;j<tree[i][1];j++){
	if(j!=0) printf(", ");
	printf("%d",tree[i][2+j]);
      }
    
    }else if(tree[i][1]==0){
      printf("leaf, [");
    }
    else {
      printf("internal node, [");
      for(j=0;j<tree[i][1];j++){
	if(j!=0) printf(", ");
	printf("%d", tree[i][j+2]);
      }
    }

   printf("]\n");
	   
    
  }

  for(i=0;i<n;i++){
    free(tree[i]);
  }
  free(tree);
  
  return;
}


int Depth(int **tree,int *oya,int depth,int ko){
  if(oya[ko]==-1)return depth;

  else return Depth(tree,oya,depth+1,oya[ko]);
}

