#include<stdio.h>

#define N 100001
#define Gard -1

typedef struct{
  int parent;
  int leftch;
  int rightch;
}Tree;

int Caldepth(int,Tree *);
void List(int);

int main(){
  Tree Root[N];
  int loop,freq,chnode,numnode,temp,count,change,list;
  int i,j;

  scanf("%d",&loop);
  for(i=0;i<loop;i++){
    Root[i].parent=Gard;
    Root[i].leftch=Gard;
    Root[i].rightch=Gard;
  }

  for(i=0;i<loop;i++){
    scanf("%d %d",&freq,&chnode);
    
    for(j=0;j<chnode;j++){
      scanf("%d",&numnode);

      if(j==0){
	Root[freq].leftch=numnode;
	Root[numnode].parent=freq;
	temp=numnode;
      }

      else{
	Root[temp].rightch=numnode;
	Root[numnode].parent=freq;
	temp=numnode;
      }
    }
  }


  for(i=0;i<loop;i++){
    printf("node %d: parent = %d, ",i,Root[i].parent);

    change=i;
 
    printf("depth = %d, ",Caldepth(change,Root));
    
    if(Root[i].parent==Gard){
      printf("root, [");
    }

    else if(Root[i].leftch==Gard){
      printf("internal node, [");
    }

    else{
      printf("leaf, [");
    }

    list=Root[i].leftch;

    List(list);
    
  }

  return 0;
}


int Caldepth(int change,Tree *Root){
  int count=0;
  
   while(Root[change].parent>Gard){
      change=Root[change].parent;
      count++;
    }

   return count;
}


void List(int list){
  int count=0;

  while(list>Gard){
    if(count==0){
      printf("%d",list);
    }
      
    else{
      printf(", %d",list);
    }
  }

  printf("]\n");
}

