#include<stdio.h>
#include<string.h>
#define N 25

typedef struct{
  int parent;
  int child[N];
  int depth;
  char type[N];
  int cc;
}node;

node C[N];

int main(void){
  int n,id,i,j,k;
  char T[3][N] = {"root","internal node","leaf"};
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    C[i].parent = -1;
  } 
  
  for(i=0;i<n;i++){
    
    scanf("%d",&id);//id
    scanf("%d",&C[id].cc);//degree
    
    //make child
    
    for(j=0;j<C[id].cc;j++){
      
      scanf("%d",&C[id].child[j]);
    }
    
    //information
    
    for(j=0;j<C[i].cc;j++){
      
      if(C[i].child[j] != -1) C[C[i].child[j]].parent = id;  
    }
  }
  
    for(i=0;i<n;i++){
    
    if(C[i].parent == -1){
      C[i].depth = 0;
      strcpy(C[i].type,T[0]); 
    }
    
    else if(C[i].parent != -1){
      C[i].depth = C[C[i].parent].depth +1; 
      
      if(C[i].cc == 0) strcpy(C[i].type,T[2]);
      
      if(C[i].cc != 0) strcpy(C[i].type,T[1]);
      
    }
  }
  
  for(i=0;i<n;i++){
    
    
    printf("node %d: parent = %d, depth = %d, %s, ", i, C[i].parent,C[i].depth, C[i].type);
    
    if(C[i].cc != 0){
      printf("[");
      for(j=0;j<C[i].cc;j++){
	if(j==C[i].cc-1) printf("%d",C[i].child[j]);
	else printf("%d, ",C[i].child[j]);
      }
      printf("]\n");
    }
    else printf("[]\n");
  }
  return 0;
}

