#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct{
  int p;
  int r;
  int l;
} Node;
int main(){
  int n,i,j,degree,num,point,temp,a,flag=0,depth=0,sum=0;
  char str[20];
  Node T[100000];
  for(i=0;i<100000;i++){
    T[i].p=T[i].r=T[i].l=-1;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&point,&degree);
    sum+=degree;
    for(j=0;j<degree;j++){
      scanf("%d",&num);
      if(j==0){
      T[point].l=num;
      T[num].p=point;
      }
      else {
	T[num].p=point;
	T[temp].r=num;
      }
      temp=num;
    }
  }
  
  for(i=0;i<=sum;i++){
    depth=0;
    flag=0;
    j=i;
    while(T[j].p!=-1){
      depth++;
      j=T[j].p;
    }
      
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth);
    if(T[i].p==-1) printf("root, ");
    else if(T[i].l==-1){ printf("leaf, []\n"); continue;}
  else printf("internal node, ");
    if(T[i].l!=-1){
      flag=1;
      num=T[i].l;
      printf("[%d",num);
      while(T[num].r!=-1){
	printf(", %d",T[num].r);
	num=T[num].r;
      }
      printf("]");
    }
    if(flag==0)printf("[]");	
    printf("\n");
  }
  return 0;
}

  
  
   
    
      
    
  
	   

