#include <stdio.h>
#define N 100000
#define M 3

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

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

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

  // input the number of nodes
  scanf("%d", &n);
  
  // initialization
  for(i = 0; i < n; i++) {
    node[i].parentid = -1;
  }

  // input the information of nodes
  for(i = 0; i < n; i++) {
    scanf("%d", &id);  // input the node id
    scanf("%d", &node[id].nchild);  // input the number of children
    for(j = 0; j < node[id].nchild; j++) {
      scanf("%d", &childid);  // input the child id
      node[childid].id = childid;
      append(id, &node[id], &node[childid]);
    }
  }
  
  // output
  for(i = 0; i < n; i++) {
    // node id
    printf("node %d: ", i);
    // the parent of node

    printf("parent = %d, ", node[i].parentid);
    // node depth
    printf("depth = %d, ", node[i].depth);
    // the type of node
    if(node[i].parentid == -1) printf("root, ");
    else if(node[i].child == NULL) printf("leaf, ");
    else printf("internal node, ");
    // child
    printf("[");
    nextchild = node[i].child;
    for(j = 0; j < node[i].nchild; j++) {  
      printf("%d", nextchild->id);
      if(j != node[i].nchild - 1) printf(", ");
      nextchild = nextchild->next;
    } 
    printf("]\n");
  }

  return 0;
}

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

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

