#include<stdio.h>

#define N 100000
#define NIL -1

void degree(int);

typedef struct{
  int id;
  int p;
  int l;
  int r;
}Node;

Node T[N];
int x = 0;

int main(){ int i, j, n, c, k, newcode, left, right;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++) T[i].id = T[i].p = T[i].l = T[i].r = NIL;

  for(i = 0; i < n; i++){
    scanf(" %d%d", &newcode, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &c);
      T[c].p = newcode;
      if(j == 0) T[newcode].l = c;
      else T[left].r = c;
      left = c;
    }
  }
  
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, ", i, T[i].p);
    if(T[i].id == NIL) printf("depth = %d, ", x);
    else {
      x++;
      printf("depth = %d, ", T[i].p);
    }
    if(T[i].p == NIL) printf("root, [");
    else if(T[i].l == NIL) printf("leaf, [");
    else printf("internal node, [");
    
    degree(T[i].l);
    
    printf("]\n");

   }

   return 0;

 }

 void degree(int nodeid){
   if(nodeid != NIL){  
     if(x != 0){
       printf(", ");
     }
     printf("%d", nodeid); 
     x++;
    degree(T[nodeid].r);
  }
}