/****************/ 
/* Rooted Trees */
/****************/
#include <stdio.h>
#define MAX 100000
#define NIL -1

/* Struct Declaration */
typedef struct node {
  int parent;
  int left;
  int right;
}Node;

/* Prototype Declaration */
void setDepth(int, int);
void printChildren(int);

/* Global Variable */
Node U[MAX];
int depth[MAX];

int main() {
    int i, j, n, id, k, data, p, d;

    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
      U[i].parent = NIL;
      U[i].left = NIL;
      U[i].right = NIL;
    }

    for ( i = 0; i < n; i++ ) {

      scanf("%d%d", &id, &k);
      
      for ( j = 0; j < k; j++ ) {
        scanf("%d", &data);
        if ( j == 0 ) U[id].left = data;
        else U[p].right = data;
        p = data;
        U[data].parent = id;
      }

      if ( U[i].parent == NIL ) d = i;

    }

    setDepth(d, 0);

    for ( i = 0; i < n; i++ ) printChildren(i);

    return 0;
}

void setDepth(int u, int p) {
  depth[u] = p;
  if ( U[u].right != NIL ) setDepth(U[u].right, p);
  if ( U[u].left != NIL ) setDepth(U[u].left, p + 1);
  return;
}

void printChildren(int u) {
  int c = U[u].left;

  printf("node %d: ", u);
  printf("parent = %d, ", U[u].parent);
  printf("depth = %d, ", depth[u]);

  if ( U[u].parent == NIL ) printf("root, ");
  else if ( U[u].left == NIL ) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  while ( c != NIL ) {
    printf("%d", c);
    if(U[c].right != NIL) printf(", ");
    c = U[c].right;
  }
  printf("]\n");
}