#include <stdio.h>
#define NIL -1
typedef struct{
  int left,right,parent;
}Tree;
void setDepth(int ,int );

int n,depth[100000];
Tree Node[100000];

int main(void){
  int i,j,node,parent,child,prev_child;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    Node[i].left=NIL;
    Node[i].right=NIL;
    Node[i].parent=NIL;
  }

  
  for(i=0;i<n;i++){
    scanf("%d%d",&node,&parent);
    for(j=0;j<parent;j++){
      scanf("%d",&child);
      if(j!=0)
        /*2,3,....,parent
         right node(sibling) is added as child*/
        Node[prev_child].right=child;
      else
        //first step
        Node[node].left=child;
      prev_child=child;
      Node[child].parent=node;
    }
  }


  for(i=0;i<n;i++)
    //set root node number
    if(Node[i].parent==NIL)node=i;

  setDepth(node,0);
 i=0;
  while(i<n){
    printf("node %d: ",i);
    printf("parent = %d, ",Node[i].parent);
    printf("depth = %d, ",depth[i]);
    if(Node[i].left==NIL && i!=0)printf("leaf, []\n");
    else{
      if(Node[i].parent==NIL)
        printf("root, [");
      else
        printf("internal node, [");

      j=0;
      child=Node[i].left;
      while(child!=NIL){
        if(j++!=0)printf(", ");
        printf("%d",child);
        child=Node[child].right;
      }
      printf("]\n");
    }
    i++;
  }
  return 0;
}
void setDepth(int node,int depth_node){
  depth[node]=depth_node;
  if(Node[node].right!=NIL)
    //If there is a right node(sibling),set depth of right node.
    setDepth(Node[node].right,depth_node);
  if(Node[node].left!=NIL)
    //If there is a left node(child),set depth of left node.
    setDepth(Node[node].left,++depth_node);
}
