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

int main(){
  int i,j,n,id,l,s=0,t;
  int **node,*d,*p,*k;
  char *r[12];
  
  scanf("%d",&n);

  node = (int **)malloc(sizeof(int *) * n);
  d = (int *)malloc(sizeof(int) * n);
  p = (int *)malloc(sizeof(int) * n);
  k = (int *)malloc(sizeof(int) * n);
  
  for(i = 0 ; i < n ; i++){

    scanf("%d",&id);
    scanf("%d",&k[id]);
    
    node[id] = (int *)malloc(sizeof(int) * k[id]);

    for(j = 0 ; j < k[id] ; j++){
      scanf("%d",&node[id][j]);
    }
  }

  for(i = 0 ; i < n ; i++){

    if(k[i] > 0){
      for(j = 0 ; j < n ; j++){
	
	if(s == 1)break;
	
	for(l = 0 ; l < k[j] ; l++){
	  if(i == node[j][l]){
	    p[i] = j;
	    r[i] = "internal node, ";
	    s = 1;
	    break;
	  }
	}
	
	if(s == 0){
	  p[i] = -1;
	  r[i] = "root, ";
	}
      }
    }
    
    else if(k[i] == 0){
      for(j = 0 ; j < n ; j++){
	for(l = 0 ; l < k[j] ; l++){
	  if(i == node[j][l]){
	    p[i] = j;
	    r[i] = "leaf, ";
	    break;
	  }
	}
      }
    }
    
  }

  

  for(i = 0 ; i < n ; i++){
    s = p[i];
    d[i] = 0;
    while(s != -1){
      d[i]++;	    
      t = p[s];
      s = t;
    }
  }
    


  for(i = 0 ; i < n ; i++){
    printf("node %d: ",i);
    printf("parent = %d, ",p[i]);
    printf("depth = %d, ",d[i]);
    printf("%s",r[i]);
    
    printf("[");
    
    for(j = 0 ; j < k[i] ; j++){
      printf("%d",node[i][j]);
      if(j < k[i] - 1) printf(", ");
    }
    printf("]\n");
  }


  return 0;
}



	   
	   
 
    