#include<stdio.h>

#include <stdlib.h>
int main(){
  int j,*a[100000],n,m,i,ndnm,parent[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    parent[i]=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&ndnm,&m);
    a[ndnm]= malloc(sizeof(int)*(m+1));
    
    for(j=0;j<m;j++){
     scanf("%d",&a[ndnm][j]);
     parent[a[ndnm][j]]=ndnm;
    }
    a[ndnm][m]=-1;
  }
  int ins,count;
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,parent[i]);
    ins=parent[i];
    while(ins!=-1){
      ins=parent[ins];
      count++;
    }
    printf("depth = %d, ",count);
    count=0;
    if(parent[i]==-1){
      printf("root, ");
    }else if(a[i][0]==-1){
      printf("leaf, ");
      printf("[]\n");
      continue;
    }else{
      printf("internal node, ");
    }
    printf("[");
    for(j=0;a[i][j]!=-1;j++){
      printf("%d",a[i][j]);
    if(a[i][j+1]!=-1)
      printf(", ");
    }
    printf("]\n");
    
  }
  for(i=0;i<n;i++){
    free(a[i]);
  }
}

