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

struct {
  int id;
  int num;
  int *list_c;
  int pare;
  int depth;
  int flag;
} typedef Tree;

int main(){
  Tree *k;
  int n, id, num, p, i, j;

  scanf("%d", &n);
  k = (Tree *)malloc(sizeof(Tree) * n);

  if(k == NULL){
    printf("error!\n");
    exit(-1);
  }

  for(i = 0; i < n; i++){
    scanf("%d %d", &id, &num);
    k[id].id = id;
    k[id].num = num;
    if(num != 0){
      k[id].list_c = (int *)malloc(sizeof(int) * num);
      if( k[id].list_c == NULL){
	printf("error!\n");
	free(k);
	exit(-1);
      }
      for(j = 0; j < num; j++) scanf("%d", &k[id].list_c[j]); 
    }
  }
  
  for(i = 0; i < n; i++){
    k[i].pare = -1;
    k[i].depth = 0;
    k[i].flag = 0;
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < k[i].num; j++){
      if( i == 0) k[ k[i].list_c[j] ].flag = 1; 
      k[ k[i].list_c[j] ].pare = k[i].id;  
      k[ k[i].list_c[j] ].depth += 1; 

      p = k[i].pare;
      while(p != -1){
	k[ k[i].list_c[j] ].depth += 1; 
	p = k[p].pare;
      }
      
    }
  }
  
  for(i = 0; i < n; i++){
    if(k[i].flag == 1) k[i].depth += k[k[i].pare].depth;
  }

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", k[i].id, k[i].pare, k[i].depth);
    if(k[i].pare == -1) printf("root, [");
    else if(k[i].num != 0) printf("internal node, [");
    else printf("leaf, [");
    if(k[i].num != 0){
      for(j = 0; j < k[i].num - 1; j++) printf("%d, ", k[i].list_c[j]);
      printf("%d]\n", k[i].list_c[j]);
    }
    else printf("]\n");
  }

  return 0;
}