#include<stdio.h>
#define N 20
#define NIL -1
typedef struct Trees{
  int parent;
  int right;
  int left;
} tree;
tree tr[N];
int depth[N];
void print(int);
void culDepth(int, int);
int main() {
  int i, j, n, node,  m, right, left, c, rooti;
  scanf("%d", &n);
  for ( i = 0; i < n; i++) {
    tr[i].parent = NIL;
    tr[i].left = NIL;
    tr[i].right = NIL;
  }
  for (i = 0; i < n; i++) {
    scanf("%d %d", &node, &m);
    for (j = 0; j < m; j++) {
      scanf("%d", &c);
      if( j == 0 ) {
	tr[node].left = c;
      } else {
	tr[left].right = c;
      }
      left = c;
      tr[c].parent = node;
    }
  }
  for ( i = 0; i < n; i++) {
    if ( tr[i].parent == NIL ) {
      rooti = i;
    }
  }
  culDepth(rooti,0);
  for ( i = 0; i < n; i++) {
    print(i);
  }
  return 0;
}

void print(int i) {
  int j, c;
  printf("node %d: parent = %d, depth = %d, ", i, tr[i].parent, depth[i]);
  if ( tr[i].parent == NIL ) {
    printf("root, ");
  } else if (tr[i].left == NIL){
    printf("leaf, ");
  } else {
    printf("internal node, ");
  }
  printf("[");
  c = tr[i].left;
  for (j = 0; c != NIL; c = tr[c].right) {
    if ( j != 0 ) {
      printf(", ");
    }
    printf("%d", c);
    j++;
  }
  printf("]\n");
  return ;
}
void culDepth(int i, int p) {
  depth[i] = p;
  if ( tr[i].right != NIL ) {
    culDepth(tr[i].right, p);
  }
  if ( tr[i].left != NIL ) {
    culDepth(tr[i].left, p+1);
  }
  return ;
}