#include <stdio.h>
#include <stdlib.h>
#define N 100000
struct Node{
  int parent,left,right;
};
struct Node a[N],tmp;
void initialize(int n){
  int i;
  for (i =0;i<n;i++){
    a[i].parent = a[i].right = a[i].left = -1;
  }
}
int main(){
  int n;
 
  scanf("%d",&n);
  int i;
  initialize(n);
  int my,k,j,c,el;
  for(i=0;i<n;i++){
    scanf("%d %d",&my,&k);
      
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0) a[my].left = c;
      else a[el].right = c;
      a[c].parent = my;
      el=c;
    }
  }
  int Parent,depth;
  for(i=0;i<n;i++){
    depth = 0;
    Parent = a[i].parent;
      
    while(Parent != -1){
      Parent = a[Parent].parent;
      depth++;
    }
      
    if(a[i].parent == -1){
      printf("node %d: parent = %d, depth = %d, root, [",
       i,a[i].parent,depth);
    }
    else if(a[i].left == -1) printf("node %d: parent = %d, depth = %d, leaf, [",i,a[i].parent,depth);
    else printf("node %d: parent = %d, depth = %d, internal node, [",i,a[i].parent,depth);
      
    Parent = a[i].left;
    if(Parent != -1) printf("%d",Parent);
      
    while(Parent != -1){
      Parent = a[Parent].right;
      if(Parent != -1) printf(", %d",Parent);
    }
    printf("]\n");
  }
  
  return 0;
}