#include <stdio.h>
#include <stdlib.h>
typedef struct {
  int p;//parent
  int dep;//depth
  int deg;//degree
  int *child;//children    
} node;
int main(){
  
  int i,j,n,d,id,c,a;
  node *tree;
  
  scanf("%d",&n);
  tree = (node*)malloc(sizeof(node)*n);
  
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&d);
    tree[i].child = (int*)malloc(sizeof(int)*d);
    tree[i].deg = d;
    if(i==0)tree[i].p = -1;
    
    for(j=0;j<d;j++){
      //printf("j = %d\n",j);
      scanf("%d",&tree[i].child[j]);
      tree[tree[i].child[j]].p = i;
    }

    c=0;
    a=i;
    while(tree[a].p>-1){
      a = tree[a].p;
      c++;
    }
    tree[i].dep = c;    
    
  }
  
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].p,tree[i].dep);
    if(tree[i].deg == 0)printf("leaf, ");
    else if(tree[i].p == -1)printf("root, ");
    else printf("internal node, ");
    printf("[");
    for(j=0;j<tree[i].deg;j++){
      if(j == tree[i].deg - 1)printf("%d",tree[i].child[j]);
      else printf("%d, ",tree[i].child[j]);
    }
    printf("]\n"); 
  }
  
  for(i=0;i<n;i++){
    free(tree[i].child);
  }
  free(tree);
  
  
  return 0;
  }

