
#include<stdio.h>
#define MAX 100005
#define NIL -1

void print(int);

struct Node {
  int p,l,r;
};

struct Node Tree[MAX];

int depth(int,int);

int Depth[MAX];

int main(){
  int h,i,j,nu,dep,c,l,r;

  scanf("%d",&h);

  for(i=0;i<h;i++){
    
    Tree[i].p = Tree[i].l = Tree[i].r = NIL;
  }
  
  for(i=0;i<h;i++){
    
    scanf("%d%d",&nu,&dep);
    
    for(j=0;j<dep;j++){

      scanf("%d",&c);
      
      if(j==0)Tree[nu].l=c;
      
      else Tree[l].r = c;
      
      l=c;
      
      Tree[c].p = nu;
      
    }
  }

  for(i=0;i<h;i++){
    if(Tree[i].p == NIL)r=i;
  }

  depth(r,0);
  
  for(i=0;i<h;i++) print(i);

  return 0;
}

void print(int x){
  int i,p;
  
  printf("node %d: ",x);
  
  printf("parent = %d, ",Tree[x].p);
  
  printf("depth = %d, ",Depth[x]);

  if(Tree[x].p == NIL)printf("root, ");
  
  else if(Tree[x].l == NIL)printf("leaf, ");
  
  else printf("internal node, ");

  printf("[");
  
  for( i=0, p =Tree[x].l;p!=NIL;i++, p = Tree[p].r){
    
    if(i>0)printf(", ");
    
    printf("%d",p);
    
  }
  
  printf("]\n");
  
}

int depth(int x,int y){
  
  Depth[x] = y;
  
  if(Tree[x].r != NIL)depth(Tree[x].r,y);
  
  if(Tree[x].l != NIL)depth(Tree[x].l,y+1);
  
}

