#include <stdio.h>

typedef struct{
  int p;
  int l;
  int r;
}Tree;

int n,k;

void output(Tree *);
int makedepth(Tree *,int);

int main(){
  Tree a[100000];
  int d[100000];
  int b,i,j,id,l,r;

  scanf("%d",&n);
   for(i = 0; i < n; i++){
    a[i].p = a[i].l = a[i].r = -1;
   }
   
  for(i = 0; i < n; i++){
  scanf("%d%d",&id,&k);

  for(j = 0; j < k; j++){
   scanf("%d",&b);
   if(j == 0){
   a[id].l = b;
   }
   else{
     a[l].r = b;
   }
   l = b;
   a[b].p = id;
  }
 }
 for(i = 0; i < n; i++){
   if(a[i].p == -1){
   r = i;
   break;
   }
  }
 output(a);
  return 0;
}

void output(Tree a[]){
  int i,b;
 
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, ",i,a[i].p);
    printf("depth = %d, ",makedepth(a,i));
    
    if(a[i].p == -1)printf("root, ");
    else if(a[i].l == -1)printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    
    b = a[i].l;
    
    while(b != -1){
      printf("%d",b); 
      if(a[b].r != -1)printf(", ");
      
     b = a[b].r;
    }
    printf("]\n");
 }
}

int makedepth(Tree a[],int d){
  int prev,num = 0;

  prev = d;
  while(a[prev].p != -1){
    num++;
    prev = a[prev].p;
  }
  return num;
}

