#include <stdio.h>
#define MAXN 1000001
#define NIL -1

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

struct Node rootTree[MAXN];


int getDepth(int u)// book P190
{
  int d = 0;
  while (rootTree[u].p != NIL){
    u = rootTree[u].p;
    d++;
  }
  return d;
}

void print(int N){
  int i, j, c, d;
  
  for ( i = 0; i <N; i++ ){
    d = getDepth(i);

    printf("node %d: parent = %d, depth = %d, ",i,rootTree[i].p, d);

    if ( rootTree[i].p == NIL ) printf("root, ");
    else if ( rootTree[i].l == NIL ) printf("leaf, ");
    else printf("internal node, ");
    
    printf("[");
    
    // printChildern(i)  book 191
    c = rootTree[i].l;
    j =0;
    while (c != NIL){
      if (j) printf(", ");
      printf("%d", c);
      c = rootTree[c].r;
      j=1;
    }

    
    printf("]\n");

    }
}

int main(void)
{
  int n,i,j,k, v,c,l;
  scanf("%d", &n);   // n nodes
  
  // init rootTree
  for ( i = 0; i < n; i++ ) {
    rootTree[i].p=NIL;
    rootTree[i].l=NIL;
    rootTree[i].r=NIL;
  }

  //input v for current node
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &k);  //id,k
    for (j = 0; j < k; j++){// input k childeren
      scanf("%d", &c);
      if ( j == 0 ) rootTree[v].l = c; // WA error  v is not i
      else rootTree[l].r = c;
      l = c;
      rootTree[c].p = v;
    }
  }
  print(n);
  
  return 0;
}
