#include<stdio.h>
#include<stdlib.h>
#define N 10

typedef struct{
  int parent;
  int left;
  int right;
}Node;

int main(){
  int point,number,i,j,a,b,n,deep=0,place,count=0,k;
  int *Deep;
  int num[N];
  Node *Tree;

  scanf("%d",&n);
  Tree =  ( Node * )malloc( sizeof(Node) * n );
  Deep = ( int * )malloc( sizeof(int) * n );

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

    Tree[i].parent = -1;
    Tree[i].left = -1;
    Tree[i].right = -1;
  }

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

    for( j = 0 ; j < number ; j++ ){
      scanf("%d",&a);
      if( i == 0 ){
	num[j] = a;
	count++;
      } 
      Tree[a].parent = point;

      if( j == 0 ) Tree[point].left = a;
      else Tree[b].right = a;

      b = a;
    }
  }

  //  printf("%d",Tree[2].parent);
  for( i = 0 ; i < n ; i++ ){
    place = i;
    while( Tree[place].parent != -1 ){
      deep++;
      place = Tree[place].parent;
    }
    Deep[i] = deep;
    deep = 0;
  }

  /*  for( i = 0 ; i < n ; i++ ){
    printf("node %d: parent = %d, depth = %d, ",i,Tree[i].parent,Deep[i]);

    if( Tree[i].parent == -1 ){
      printf("root, [");
      for( k = 0 ; k < count-1 ; k++ ) printf("%d,",num[k]);
      printf("%d",num[count-1]);
    }

    else if( Tree[i].left == -1 ) printf("leaf, [");
    else{
      printf("internal node, [%d, ",Tree[i].left);
      i = Tree[i].left;
      if( Tree[i].right != -1 ) printf(", ");
      while( Tree[i].right == -1 ){
	printf("%d",Tree[i].right);
	i = Tree[i].right;
	if( Tree[i].right != -1 ) printf("%d",Tree[i].left);
      }
    }
    printf("]\n");
  }
  return 0;
} */
  for(i=0;i<n;i++){
  printf("node %d: parent = %d, depth = %d, ",i ,Tree[i].parent ,Deep[i]);
 
  if(Tree[i].parent == -1) {
    printf("root, ");
  }
 
  else if(Tree[i].left == -1) {
    printf("leaf, ");
  }
 
  else if(Tree[i].left != -1) {
    printf("internal node, ");
  }
 
  printf("[");
 
  if(Tree[i].left != -1) {
    printf("%d",Tree[i].left);
    i=Tree[i].left;
   
 
    if(Tree[i].right != -1)printf(", ");
 
    while(1){
    if(Tree[i].right == -1)break;
 
      printf("%d",Tree[i].right);
      i=Tree[i].right;
 
      if(Tree[i].right != -1) {
    printf(", ");
      }
 
    }
  }
   
  printf("]\n");
  }
  return 0;
}