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

typedef struct{
  int parent;
  int left;
  int right;
} node;

int main(){
  node *ar,*t;
  int i,j,n,id,c,k,a,depth;

  scanf("%d",&n);
  ar=(node *)malloc(sizeof(node)*n);
  t=ar;
  for(i=0;i<n;i++){
    t[i].parent=-1;
    t[i].left=-1;
    t[i].right=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);    
    for(j=0;j<k;j++){
      scanf("%d",&c);
      t[c].parent=id;
      if(j==0)t[id].left=c;
      else t[a].right=c;
      a=c;
    }
  }
  for(i=0;i<n;i++){
    a=t[i].parent;
    depth=0;
    while(a!=-1){
      depth++;
      a=t[a].parent;
    }
    printf("node %d: parent = %d, depth = %d, ",i,t[i].parent,depth);
    if(t[i].parent==-1)printf("root, [");
    else if(t[i].left==-1)printf("leaf, [");
    else printf("internal node, [");
    a=t[i].left;
    if(a!=-1){
      printf("%d",t[i].left);
      while(t[a].right!=-1){
	printf(", %d",t[a].right);
	a=t[a].right;
      }
    }
    printf("]\n");
  }
  return 0;
}