#include<stdio.h>
 
#define MAX 100006
 
struct Node{
  int p;
  int l;
  int r;
};
 
struct Node C[MAX];
 
int n, H, D[MAX];
 
int getDepth(int u){
  int d = 0;
   
  while(N[u].p >= 0){
    u = N[u].p;
    d++;
  }
   
  return d;
}
 
void printTree(int u){
  int t;
 
  if(C[u].p == -1) printf("node %d: parent = %d, depth = %d, root, ", u, C[u].p, D[u]);
   
  else if(C[u].l == -1) printf("node %d: parent = %d, depth = %d, leaf, ", u, C[u].p, D[u]);
   
  else printf("node %d: parent = %d, depth = %d, internal node, ", u, C[u].p, D[u]);
     
  printf("[");
 
  t = u;
 
  if(C[t].l != -1){
    printf("%d", C[t].l);
 
    if(C[C[t].l].r == -1) printf("]\n");
 
    else printf(",");
 
    t = C[t].l;
 
    while(C[t].r != -1){
      printf(" %d",N[t].r);
       
      if(C[C[t].r].r == -1) printf("]\n");
 
      else printf(",");
 
      t = C[t].r;
    }
  }
   
  else printf("]\n");
}
 
main(){
  int i, j, d, v, c, l, r;
   
  scanf("%d", &n);
   
  for(i = 0; i < n; i++){
    C[i].p = C[i].l = C[i].r = -1;
  }
   
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
 
    for(j = 0; j < d; j++){
      scanf("%d", &c);
 
      C[c].p = v;
       
      if(j == 0) C[v].l = c;
       
      else if (j >= 1) C[r].r = c;
      r = c;
    }
  }
   
  for(i = 0; i < n; i++) D[i] = getDepth(i);
   
  for(i = 0; i < n; i++) printTree(i);
  return 0;
}