#include <stdio.h>
#include <stdlib.h>
int main (){
  int n;
  // int **c;
   int *id;
  int *p;
  int *d;
  int *deg;
  int i,j,k,l,maxdeg = 0;
  int c[100000][70000];
  scanf("%d", &n);
  k = 2 * n;
  /* c = malloc(sizeof(int) * (n+1));
  for (i = 0; i < n; i++) {
    c[i] = malloc(sizeof(int) * k);
    }*/
  id = malloc(sizeof(int) * (n+1));
  p = malloc(sizeof(int) * (n+1));
  d = malloc(sizeof(int) * (n+1));
  deg = malloc(sizeof(int) * (n+1));
  
  for(i = 0; i < n; i++){
    scanf("%d",&id[i]);
    scanf("%d",&deg[id[i]]);
    for(j = 0; j < deg[id[i]]; j++){
      scanf("%d",&c[id[i]][j]);
    }
  }
 

   for(i = 0; i < n;i++){
    p[i] =-1;
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
       for(k = 0; k < deg[id[j]]; k++){
	 if(id[i] == c[id[j]][k]){
	   p[id[i]] = id[j];
	   break;
	 }
       }
       if(p[id[i]] == id[j])break;
    }
  }

  for(i = 0; i < n; i++){
    if(p[id[i]] == -1){
      d[id[i]]=0;
      for(j = 0;j < deg[id[i]]; j++){
	d[c[id[i]][j]] = 1;
	  }
      break;
    }
  }

  for(i = 0;i < n; i++){
    for(k = 1; k<20; k++){
      if(d[id[i]] == k){
       for(j = 0;j < deg[id[i]]; j++){
	 d[c[id[i]][j]] = k+1;
       }
    }
    }
  }

  
  
  for(i = 0; i < n; i++){
    
    for(j = 0; j < n; j++){
      if(id[j] == i){
	printf("node %d: parent = %d, depth = %d, ",id[j],p[id[j]],d[id[j]]);
	if(p[id[j]] == -1){
	  printf("root, [");
	}
	else if(deg[id[j]] == 0){
	  printf("leaf, [");
	}
	else  {
	  printf("internal node, [");
	}
	if(deg[id[j]]>0){
	for(l = 0; l < deg[id[j]]-1; l++){
	  printf("%d, ",c[id[j]][l]);
	    }
	printf("%d",c[id[j]][l]);}
	printf("]\n");
	break;
      }
    }
  }
  
	return 0;
}