#include<stdio.h>

int main(){
  int id[100001],p[100001],d[100001],k[100001],n,count=0,i,j,c[100001][10];
  

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

  for(i=0;i<n;i++){
    if(i==0){
      printf("node 0: parent = -1, depth = 0, root,[");
      for(j=0;j<k[i]-1;j++) printf("%d, ",c[0][j]);
      printf("%d]",c[0][k[i]-1]);
    }
    else if(k[i]==0) printf("node %d: parent = %d, depth = %d, leaf,[]",id[i],p[i],d[i]);
    else{
      printf("node %d: parent = %d, depth = %d, internal node,[",id[i],p[i],d[i]);
      for(j=0;j<k[i]-1;j++) printf("%d, ",c[i][j]);
      printf("%d]",c[i][k[i]-1]);
    }
    printf("\n");
  }
  
  return 0;
}