#include<stdio.h>
#include<string.h>
#define N 100000
typedef struct{
  int p;
  int d;
  char type[13];
  int c[N];
}id;

int main(){
  int i,j,n,k,l;
  id A[20];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    scanf("%d",&j);
    for(l=0;l<j;l++) scanf("%d",&A[k].c[l]);
  }
  
  for(i=0;i<n;i++){
    if(A[i].c[0]==NULL) continue;   
    j=0;
    while(A[i].c[j]!=NULL){
      k=A[i].c[j];
      A[k].p=i+1;
      j++;   
    }
  }
  
  for(i=0;i<n;i++){
    if(A[i].p==NULL) {
      A[i].p=-1;
      continue;
    }
    A[i].p=A[i].p-1;
  }
  printf("%d\n",A[1].p);
  
  for(i=0;i<n;i++){ 
    k=i;
    A[i].d=0;
    while(A[k].p!=-1){
      A[i].d++;
      k=A[k].p;      
    }    
    if(A[i].d==0) strcpy(A[i].type,"root,");
    else if (A[i].c[0]==NULL) strcpy(A[i].type,"leaf,");
    else strcpy(A[i].type,"internal node,"); 
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, %s",i,A[i].p,A[i].d,A[i].type);
    if(A[i].type[0]=='l'){
      printf(" []\n");
      continue;
    }      
    j=0;
    printf(" [");
    while(A[i].c[j]!='\0'){
      printf("%d",A[i].c[j]);
      if(A[i].c[j+1]=='\0')printf("]\n");
      else printf(", ");
      j++;
      
    }
  }
  return 0;
}