#include<stdio.h>
#define NIL -1
#define MAX 102000


struct Node{ int p, l, r;
};
struct Node T[MAX];
int n, H, D[MAX];

int wowDep(int);
void print(int);

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

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &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;
    }
  }
  
  H = 0;
  for ( i = 0; i < n; i++ ){
    D[i] = wowDep(i);
    if ( D[i] > H ) H = D[i];
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

int wowDep(int a){
  int depth = 0;
  for(; T[a].p != NIL ;depth++) a = T[a].p;
  return depth;
}
void print(int a){
  int i, c;
  printf("node %d: ", a);
  printf("parent = %d, ", T[a].p);
  printf("depth = %d, ", D[a]);

  if ( T[a].p == NIL ) printf("root, ");
  else if ( T[a].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = T[a].l; c != NIL; i++, c = T[c].r){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

