#include<stdio.h>
#define M 100000
typedef struct{
  int k, d, c[10], p , type;

}node;




int main(){
  node T[M];
  int n,i,a,b,deep=1,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    T[i].k=b;
    if(a==0){
T[i].type=-1;
 T[i].p=-1;
    }
    else if(b>0)T[i].type=0;
    else T[i].type = 1;
    for(j=0;j<b;j++){
      scanf("%d",&a);
      T[a].p=i;
      T[a].d=T[i].d+1;
      T[i].c[j]=a;
    }
  }

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



  return 0;
}