#include<stdio.h>
#include<stdlib.h>


typedef struct Node{
  int jisuu;
  int *child;
  int parent;
}Node;



int get_dep(Node *node,int soeji){
  int dep=0;
  Node x;
  x=node[soeji];
  while(x.parent!=-1){
    x=node[x.parent];
    dep++;
  }
  return dep;
}



int main(){
  int n,i,j,yomisute;
  scanf("%d",&n);
  Node *node;
  node=malloc(n*sizeof(Node));
  for(i=0;i<n;i++){
    scanf("%d",&yomisute);
    scanf("%d",&(node[i].jisuu));
    node[i].child=malloc( (node[i].jisuu)*sizeof(int) );
    node[i].parent =-1;
    for(j=0;j<node[i].jisuu;j++) scanf("%d",&(node[i].child[j]));
  }
  int cnt=0;
  for(i=0;i<n;i++){
    for(j=0;j< node[i].jisuu;j++){
      node[node[i].child[j]].parent=i;
      cnt+=1;
    }
    if(cnt==n-1) break;
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d",i,node[i].parent,get_dep(node,i));
    if(node[i].parent==-1) printf(", root");
    else if(node[i].jisuu==0) printf(", leaf");
    else printf(", internal node");
    printf(", [");
    for(j=0;j<node[i].jisuu -1;j++) printf("%d, ",node[i].child[j]);
    if(node[i].jisuu!=0) printf("%d",node[i].child[node[i].jisuu -1]);
    printf("]\n");
  }
  return 0;
}






  