#include <stdio.h>


int MAX=100000;





int main(){
  int p,l,k,n,i,j,I,count=0,flag=0,flag2=0;
  int tmp;
  scanf("%d",&n);
  int id[n];
  int K[n];
  int c[n][MAX];


  for(i=0;i<n;i++){
    scanf("%d",&id[i]);
    scanf("%d",&k);
    K[i]=k;
    for(j=0;j<k;j++){
      scanf("%d",&c[i][j]);
    }
  }






  for(i=0;i<n;i++){
  for(l=0;l<n;l++){
    if(id[l]==i)p=l;
  }

    printf("node %d:",id[p]);

    j=0;
    while(j!=n){
      for(k=0;k<K[j];k++){
	if(id[p]==c[j][k]){
	  printf(" parent = %d,",id[j]);
	  flag=1;
	}
      }
    j++;
    }
    j=0;
    if(flag!=1){
      tmp=-1;
      printf(" parent = %d,",tmp);
    }


    

    I=id[p];
    j=0;
    flag2=0;
    while(j!=n){
      for(k=0;k<K[j];k++){
	if(I==c[j][k]){
	  count++;
	  I=id[j];
	  j=0;
	  flag2=1;

	}
      }
      j++;
    }
    if(flag2==1)printf(" depth = %d,",count);
    else{
      tmp=0;
      printf(" depth = %d,",tmp);
    }
    flag2=0;
    count=0;
    j=0;

    if(flag!=1)printf(" root,");
    else if(K[p]!=0)printf(" internal node,");
    else printf(" leaf,");
    


   
    printf(" [");
    if(K[p]!=0){  
      for(k=0;k<K[p]-1;k++){
	printf("%d, ",c[p][k]);
      }
      printf("%d",c[p][k]);
    }
    printf("]\n");

    flag=0;

  }

  

  


  return 0;
}