#include<stdio.h>
#include<stdlib.h>
//ST[1]は親はST[0]|は子の数
int *ST[100000];
int ST2[100000][2];
int main(){
  int n,i,j,NN,MN,free;
  scanf("%d",&n);
  for(i=0;i<n;i++)ST2[i][1]=-1;
  for(i=0;i<n;i++){
    scanf("%d%d",&NN,&MN);
    ST[NN]=malloc(MN*sizeof(int));
    ST2[NN][0]=MN;
    for(j=0;j<MN;j++){
      scanf("%d",&free);
      ST[NN][j]=free;
      ST2[free][1]=NN;
    }
  }
  for(i=0;i<n;i++){
    j=i;
    free=0;
    printf("node %d: parent = %d,",i,ST2[i][1]);
    while(ST2[j][1]!=-1){
      j=ST2[j][1];
      free++;
    }
    printf(" depth = %d, ",free);
    if(ST2[i][1]==-1)printf("root,");
    else{
      if(ST2[i][0]==0)printf("leaf,");
      else printf("internal node,");
    }printf(" [");
    for(free=0;free<ST2[i][0];free++){
      if(ST2[i][0]==1){printf("%d",ST[i][0]);break;}
      if(free==0) printf("%d,",ST[i][free]);
      else if(free!=ST2[i][0]-1)printf(" %d,",ST[i][free]);
      else printf(" %d",ST[i][free]);
    }
    printf("]");
    printf("\n");
  }
  return 0;
}

