#include <stdio.h>
#include <stdlib.h>

#define NIL -1

struct _n{
  int id;
  int val;
  int depth;
  int parent;
  struct _n *parenttree;
  struct _n *childtree;
  struct _n *nexttree;
};

typedef struct _n *Tree;

Tree makeTree(int, int, int, Tree, Tree);
void addTree(Tree);
void printTree(Tree);

Tree ori;
int nodenum;

int main(){
  Tree n;
  int i, num;

  scanf("%d", &nodenum);
  
  ori = makeTree(0, NIL, NIL, NULL, NULL);

  addTree(ori);
  
  printTree(ori);
  
  return 0;
}

Tree makeTree(int val, int parent, int depth, Tree parenttree, Tree nexttree){
  Tree n;
  
  n = (Tree)malloc(sizeof(struct _n));
  n->val = val;
  n->parent = parent;
  n->depth = depth+1;
  n->parenttree = parenttree;
  n->nexttree = nexttree;
  
  return n;
}

void addTree(Tree parenttree){
  Tree new;
  Tree n;
  int i, num, val;

  scanf("%d %d", &parenttree->id, &num);
  
  for(i = 0; i < num; i++){
    scanf("%d", &val);
    new = makeTree(val, parenttree->val, parenttree->depth,parenttree, NULL);
    if(i == 0){
      parenttree->childtree = new;
      n = new;
    }
    else{
      n->nexttree = new;
      n = n->nexttree;
    }
  }
  
  n = parenttree->childtree;
  
  while(n != NULL){
    addTree(n);
    n = n->nexttree;
  }
  
}

void printTree(Tree t){
  Tree n;
  n = t->childtree;
  
  printf("node %d: parent = %d, depth = %d, ", t->id, t->parent, t->depth);
  if(t->parent == -1){
    printf("root, ");
  }
  else if(t->childtree != NULL){
    printf("internal node, ");
  }
  else{
    printf("leaf, ");
  }
  
  printf("[");
  while(n != NULL){
    if(n->nexttree !=NULL){
      printf("%d, ", n->val);
    }
    else{
      printf("%d", n->val);
    }
    n = n->nexttree;
  }
  printf("]\n");
 
  if(t->childtree != NULL){
    printTree(t->childtree);
  }
  
  if(t->nexttree != NULL){
    printTree(t->nexttree);
  }
}

