#include<stdio.h>
#include<string.h>
#define N 100000
typedef struct{
  int p;
  int d;
  char type[13];
  char c[N];
}id;
 
int main(){
  int i,j,n,k,l;
  char k1;
  id T[20];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    scanf("%d",&l);
    for(j=0;j<l;j++) scanf(" %c",&T[k].c[j]);
  }
  for(i=0;i<n;i++){
    if(T[i].c[0]=='\0') continue;   
    j=0;
    while(T[i].c[j]!='\0'){
      k1=T[i].c[j];
      k=atoi(&k1);
      T[k].p=i+1;
      j++;   
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NULL) {
      T[i].p=-1;
      continue;
    }
    T[i].p=T[i].p-1;
  }
  
  for(i=0;i<n;i++){ 
    k=i;
    T[i].d=0;
    while(T[k].p!=-1){
      T[i].d++;
      k=T[k].p;      
    }    
    if(T[i].d==0) strcpy(T[i].type,"root,");
    else if (T[i].c[0]==NULL) strcpy(T[i].type,"leaf,");
    else strcpy(T[i].type,"internal node,"); 
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, %s",i,T[i].p,T[i].d,T[i].type);
    if(T[i].type[0]=='l'){
      printf(" []\n");
      continue;
    }      
    j=0;
    printf(" [");
    while(T[i].c[j]!=NULL){
      printf("%c",T[i].c[j]);
      if(T[i].c[j+1]!=NULL) printf(", ");
      j++;
    }
     printf("]\n");
  }
  return 0;
}