#include <stdio.h>
#include <stdlib.h>
 
typedef struct node{
  int p;
  int right;
  int left;
}Node;
 
Node *node,tmp;
 
int main(){
   
  int n,i,j,l,c,k,id,tmpP,depth,r;
   
  //in
  scanf("%d",&n);
   
  node = malloc(sizeof(Node)*n);
 
  //initialize
  for(i=0;i<n;i++){
    node[i].p = -1;
    node[i].right = -1;
    node[i].left = -1;
  }
   
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
     
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0) node[id].left = c;
      else node[r].right = c;
      node[c].p = id;
      r=c;
    }
  }
   
  //depthSearch & typeJudge
  for(i=0;i<n;i++){
    depth = 0;
    tmpP = node[i].p;
     
    while(tmpP != -1){
      tmpP = node[tmpP].p;
      depth++;
    }
     
    if(node[i].p == -1){
      printf("node %d: parent = %d, depth = %d, root, [",
       i,node[i].p,depth);
    }
    else if(node[i].left == -1) printf("node %d: parent = %d, depth = %d, leaf, [",
       i,node[i].p,depth);
    else printf("node %d: parent = %d, depth = %d, internal node, [",
       i,node[i].p,depth);
     
    tmpP = node[i].left;
    if(tmpP != -1) printf("%d",tmpP);
     
    while(tmpP != -1){
      tmpP = node[tmpP].right;
      if(tmpP != -1) printf(", %d",tmpP);
    }
    printf("]\n");
  }
 
  return 0;
}