#include <stdio.h>
#define N 100005

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

Node T[N];
int n,  D[N];

int rec(int u, int p){
  D[u] = p;
  if(T[u].r != -1) rec(T[u].r, p);
  if(T[u].l != -1) rec(T[u].l, p+1);
}

int main(){

  int i, j ,d, v, c, l ,r, k;
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }

  for(i=0; i<n; i++){
    scanf("%d", &v);
    scanf("%d", &d);
    for(j=0; j<d; j++){
      scanf("%d", &c);
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  for(i=0; i<n; i++){
    if(T[i].p == -1) r = i;
  }
  rec(r, 0);
    
  for(i=0; i<n; i++){
    printf("node %d; ", i);
    printf("parent = %d, ", T[i].p);
    printf("depth = %d, ", D[i]);

    if(T[i].p == -1) printf("root, ");
    else if(T[i].l == -1) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(j=0, k = T[i].l; k != -1; j++, k = T[k].r){
      if(j) printf(", ");
      printf("%d", k);
    }
    printf("]\n");
  }
  
  return 0;
}