#include <stdio.h>
#define N 100000

typedef struct node {
  int id;
  int depth;
  struct node* parent;
  struct node* child;
  struct node* next;
} NODE;

void append(int, NODE*, NODE*);
void calcDepth(NODE*);

int main(){
  int i, j, n;
  int id, nchild;
  int childid;
  NODE* last;
  NODE node[N];

  // input the number of nodes
  scanf("%d", &n);

  // input the information of nodes
  for(i = 0; i < n; i++) {
    scanf("%d", &id);  // input the node id
    scanf("%d", &nchild);  // input the number of children
    for(j = 0; j < nchild; j++) {
      scanf("%d", &childid);  // input the child id
      node[id].id = id;
      append(childid, &node[id], &node[childid]);
    }
  }
  
  // output
  for(i = 0; i < n; i++) {
    // node id
    printf("node %d: ", i);
    // the parent of node
    if(node[i].parent == NULL) printf("parent = -1, ");
    else printf("parent = %d, ", node[i].parent->id);
    // node depth
    calcDepth(&node[i]);
    printf("depth = %d, ", node[i].depth);
    // the type of node
    if(node[i].parent == NULL) printf("root, ");
    else if(node[i].child == NULL) printf("leaf, ");
    else printf("internal node, ");
    // child
    last = node[i].child;
    printf("[");
    while(last != NULL) {
      printf("%d", last->id);
      last = last->next;
      if(last != NULL) printf(", ");
    }
     
    
    printf("]\n");
  }

  return 0;
}

// function: add to the tree
void append(int id, NODE* parent, NODE* node) {
  NODE* last;

  node->id = id;
  node->parent = parent;
  node->depth = 0;
  node->next = NULL;
  if(parent == NULL){
    return;
  }
  if(parent->child == NULL) {
    parent->child = node;
  }
  else {
    last = parent->child;
    while(last->next != NULL) {
      last = last->next;
    }
    last->next = node;
  }
}

void calcDepth(NODE* node) {
  NODE* last;
  int depth = 0;

  last = node->parent;
  while(last != NULL) {
    depth++;
    last = last->parent;
  }
  node->depth = depth;
}

