#include <stdio.h>
#define N 100000

typedef struct{
  int id;
  int parent;
  int child;
  int right_sibling;
} Node;

main(){
  int n, i, j;
  int id, degree, depth, parent;
  int c[N];
  Node node[N];

  scanf("%d", &n);

  for( i = 0; i < n; i++){
    node[i].parent = -1;
    node[i].child = -1;
    node[i].right_sibling = -1;
  }

  for( i = 0; i < n; i++){
    c[0] = -1;
    scanf("%d%d", &id, &degree);

    for( j = 0; j < degree; j++){
      scanf("%d", &c[j]);
    }

    node[id].id = id;
    node[id].child = c[0];

    for( j = 0; j < degree; j++){
      node[c[j]].parent = id;
    }
    for( j = 0; j < degree; j++){
      node[c[j]]. right_sibling = c[j+1];
      if( j+1 == degree -1 ) break;
    }
    for( j = 0; j <= degree; j++){
      c[j] = -1;
    }
  }

  for( i = 0; i < n; i++){
    printf("node %d: parent = %d, ", node[i].id, node[i].parent);

    depth = 0;
    parent = node[i].parent;
    while(1){
      if( parent == -1 ) break;
      else {
        parent = node[parent].parent;
        depth++;
      }
    }

    printf("depth = %d, ", depth);

    if( node[i].parent == -1 ){
      printf("root, [");
    }
    else if( node[i].child == -1 ){
      printf("leaf, [");
    }
    else printf("internal node, [");

    if( node[i].child != -1 ){
      printf("%d", node[i].child);
      degree = node[i].child;
      while(1){
        if( node[degree].right_sibling == -1 ) break;
        else {
          printf(", %d", node[degree].right_sibling);
        degree = node[degree].right_sibling;
        }
      }
    }
    printf("]\n");
  }

  return 0;

}