#include<stdio.h>
#include<stdlib.h>
int get_d(int);
char type[3][15] = { "root", "internal node", "leaf"};
typedef struct{
  int id;
  int k;
  int *c;
  int p;
  int d;
  int typeNum;
} node;

node tree[1000000];
main(){
  int n, i, j;
  scanf("%d ", &n);
  for(i = 0; i < n; i++){
    scanf("%d %d ", &tree[i].id, &tree[i].k);
    for(j = 0; j < tree[i].k; j++){
      printf("%d", tree[i].k);
      tree[i].c = (int *)malloc(sizeof(int)*(tree[i].k));
      if(tree[i].c == NULL) exit(1);
      scanf("%d ", &tree[tree[i].id].c[j]);
    }
    tree[i].p=-1;
  }
  
  for(i = 0; i < n; i++){
    for(j = 0; j < tree[i].k; j++){
      tree[tree[i].c[j]].p = tree[i].id;
    }
    if(tree[i].p == -1)     tree[i].typeNum = 0;
    else if(tree[i].k == 0) tree[i].typeNum = 2;
    else                    tree[i].typeNum = 1;
  }
  for(i = 0; i < n; i++){
    tree[i].d = get_d(i)-1;
  }
   for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, %s, [", tree[i].id, tree[i].p, tree[i].d, type[tree[i].typeNum]);
   for(j = 0; j < tree[i].k; j++){
    if(j == tree[i].k-1) printf("%d", tree[i].c[j]);
    else                 printf("%d, ", tree[i].c[j]);
    }
   printf("]\n");
   }
   for(i = 0; i < n; i++){
  free(tree[i].c);
  }
  return 0;
}


int get_d(int p){
  if(p == 0) return 0;
  else return get_d(tree[p].p)+1;
}