#include<stdio.h>
#include<stdlib.h>
int D(int d);
typedef struct pp{
  int id;
  int k;
  int parent;
  int depth;
  int C[100];
  int J;
}P;
P *A;
int main(){
  int n,*S,i,j,N,count=0;
  
  scanf("%d\n",&n);
  
  A=(P*)malloc(n*sizeof(P));
  
  for(i=0;i<n;i++){
    scanf("%d %d",&A[i].id,&A[i].k);
    for(j=0;j<A[i].k;j++){
      scanf("%d",&A[i].C[j]);
    }
  }
  for(i=0;i<n;i++) A[i].J=0;
 
  for(i=0;i<n;i++){
    if(A[i].k!=0){
      for(j=0;j<A[i].k;j++){
	A[A[i].C[j]].parent=A[i].id;
	A[A[i].C[j]].J=1;
      }
    }
  }
  for(i=0;i<n;i++){
    if(A[i].J==0){
      N=i;
      A[i].depth=0;
      A[i].parent=-1;
    }
  }
 
  for(j=0;j<A[N].k;j++){ 
    A[A[N].C[j]].depth=D(A[N].C[j]);
  }
  

  
  for(i=0;i<n;i++){

    printf("node %d: parent = %d, depth = %d, ",A[i].id,A[i].parent,A[i].depth);
    if(A[i].parent==-1) printf("root, [");
    else if(A[i].k==0) printf("leaf, [");
    else printf("internal node, [");
    if(A[i].k!=0){
      for(j=0;j<A[i].k-1;j++){
	printf("%d, ",A[i].C[j]);
      }
      printf("%d",A[i].C[A[i].k-1]);
    }
    printf("]\n");
  }
  
  return 0;
}
int D(int d){
  int f;
  static int cc=0;
  
  if(A[d].parent==-1){
    return cc;
    cc=0;
  }else{
  cc++;
   A[d].depth=D(A[d].parent);
  }
  return cc;
}

