#include<stdio.h>
#define N 100000
 
typedef struct{
  int parent;
  int left;
  int right;
}Node;
 
Node Tree[N];
int depth(int);
int Printc(int);
 
main(){
 
  int i,n,id,k,c,q,j;
 
  scanf("%d",&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",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      Tree[c].parent=id;
      if(j==0) Tree[id].left=c;
      else Tree[q].right=c;
      q=c;
    }
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,Tree[i].parent,depth(i));
    if(Tree[i].parent == -1)  printf("root, [");
    else if(Tree[i].left == -1)  printf("leaf, [");
    else printf("internal node, [");
    Printc(Tree[i].left);
    printf("]\n");
  }
  return 0;
}
 
 
int Printc(int c){
  if(c==-1) return 0;
  if(Tree[c].right==-1) printf("%d",c);
  else {
    printf("%d, ",c);
    Printc(Tree[c].right);
  }
  return 0;
}

int depth(int c){
  if(Tree[c].parent==-1) return 0;
  return 1+depth(Tree[c].parent);
}