#include<stdio.h>

typedef struct{
  int node;
  int parent;
  int numchild;
  int depth;
  int child[100];
}Tree;

int main(){
  int n,i,j;
  scanf("%d",&n);
  Tree tree1[n],tree2[n];

for( i = 0 ; i  < n ; i++ )
    {
      tree1[i].parent = -1;
      tree1[i].depth = 0;
      scanf("%d%d",&tree1[i].node,&tree1[i].numchild);
      for( j =  0 ; j < tree1[i].numchild ; j++ ) scanf("%d",&tree1[i].child[j]);
    }


  for( i = 0 ; i < n ; i++ )  tree2[tree1[i].node] = tree1[i];     

  for( i = 0 ; i < n ; i++ )
    {
      for( j = 0 ; j < tree2[i].numchild ; j++ ) tree2[tree2[i].child[j]].parent = i;
}
 int x;

  for( i = 0 ; i < n ; i++ )
    {
      x = i;
       while(1){
	if( tree2[x].parent != -1 )
	  {
	    x = tree2[x].parent;
	    tree2[i].depth++;
	  }
	else break;
       }
      printf("node %d: parent = %d, depth = %d, ",i,tree2[i].parent,tree2[i].depth);

      if( tree2[i].numchild == 0 && tree2[i].parent != -1 ) printf("leaf, []\n");
    
          else{
	if( tree2[i].parent != -1 ){
	  printf("internal node, [");
	}
	else{ 
	  printf("root, [");
	}
	for( j = 0 ; j < tree2[i].numchild-1 ; j++ ) printf("%d, ",tree2[i].child[j]);
	if( tree2[i].numchild != 0 ) printf("%d]\n",tree2[i].child[j]);
	else  printf("]\n");
      }
    

      
    }

  return 0;
}