#include <stdio.h>
#define N 100000

typedef struct{
  int id;
  int parent;
  int child;
  int right_sibling;
} Node;

main(){
  int n, i, j;
  int id, degree, depth, parent;
  int c[N];
  Node node[N];
  
  scanf("%d", &n);
  
  for( i = 0; i < n; i++){
    node[i].parent = -1;
    node[i].child = -1;
    node[i].right_sibling = -1;
  }
  
  for( i = 0; i < n; i++){
    scanf("%d%d", &id, &degree);
    
    for( j = 0; j < degree; j++){
      scanf("%d", &c[j]);
    }

    node[id].id = id;
    node[id].child = degree;
    
    for( j = 0; j < degree; j++){
      node[c[j]].parent = id;
    }
  }
  
  for( i = 0; i < n; i++){
    for( j = i+1; j < n; j++){
      if( node[i].parent == node[j].parent ){
	node[i].right_sibling = node[j].id;
      }
    }
  }
  
  for( i = 0; i < n; i++){
    printf("node %d: parent = %d, ", node[i].id, node[i].parent);
    
    depth = 0;
    parent = node[i].parent;
    while(1){
      if( parent == -1 ) break;
      else {
	parent = node[parent].parent;
	depth++;
      }
    }
    
    printf("depth = %d, ", depth);

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

return 0;

}