#include <stdio.h>
#include <stdlib.h>
#define NIL -1

typedef struct{
  int parent;
  int left;  //左の子
  int right; //右の兄弟
}Node;

int getDepth(Node**, int);

main(){
  int n, i, j, k, id, child, child_, depth;
  Node **nodes;

  scanf("%d", &n);
  nodes = (Node**)malloc(sizeof(Node*)*n);
  for(i=0; i<n; i++){
    nodes[i] = (Node*)malloc(sizeof(Node));
    nodes[i]->parent = NIL;
    nodes[i]->left = NIL;
    nodes[i]->right = NIL;
  }

  for(i=0; i<n; i++){
    scanf("%d", &id);
    scanf("%d", &k);
    for(j=0; j<k; j++){
      scanf("%d", &child);
      nodes[child]->parent = id;
      if(j==0) nodes[id]->left = child;
      if(j>0) nodes[child_]->right = child;
      child_ = child;
    }
  }

  for(i=0; i<n; i++){
    depth = getDepth(nodes, i);
    printf("node %d: parent = %d, depth = %d, ",i, nodes[i]->parent, depth);
    
    if(depth == 0) printf("root, [");
    else if(nodes[i]->left == NIL) printf("leaf, [");
    else printf("internal node, [");

    for(j = nodes[i]->left; j != NIL;){
      printf("%d", j);
      j = nodes[j]->right;
      if(j != NIL) printf(", ");
    }

    printf("]\n");
  }

  return 0;
}

int getDepth(Node **nodes, int p){
  if(nodes[p]->parent == NIL) return 0;
  else{
    return 1 + getDepth(nodes, nodes[p]->parent);
  }
}