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

struct {
  int id;
  int num_c;
  int *list_c;
  int parent;
  int depth;
} typedef Tree;

int main(){
  Tree *t;
  int n, id, num_c, p, i, j;

  scanf("%d", &n);
  t = (Tree *)malloc(sizeof(Tree) * n);
  for(i = 0; i < n; i++){
    scanf("%d %d", &id, &num_c);
    t[id].id = id;
    t[id].num_c = num_c;
    if(num_c != 0){
      t[id].list_c = (int *)malloc(sizeof(int) * num_c);
      for(j = 0; j < num_c; j++) scanf("%d", &t[id].list_c[j]); 
    }
  }

  for(i = 0; i < n; i++){
    t[i].parent = -1;
    t[i].depth = 0;
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < t[i].num_c; j++){
      t[ t[i].list_c[j] ].parent = t[i].id;  
      t[ t[i].list_c[j] ].depth += 1; 

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