#include<stdio.h>
 
#define N 100000
  
typedef struct{
  int a;
  int b;
  int c;
  int d;
}node;
   
node A[100000];
int n;
void init(){
  int i;
  for(i=0;i<n;i++){
    A[i].b=-1;
    A[i].c=-1;
    A[i].d=-1;
  }
  return;
}
  
  
int depth(int now){
  int dep = 0; 
  while(1){
    if(A[now].b == -1)return dep;
    else {
      now=A[now].b;
      dep++;
    }
  }
}
  

int main(int argc,char *argv[]){
  int i,j,now,leaf,k;
    
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%d",&now);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&leaf);
      if(j==0){
    A[now].c=leaf;
    A[leaf].b=now;
      }
      else {
    A[now].d=leaf;
    A[leaf].b=A[now].b;
      }  
      now=leaf;
    }
  }
  for(i=0;i<n;i++){
    A[i].a=depth(i);
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,A[i].b,A[i].a);
    if(A[i].b==-1)printf("root, ");
    else if(A[i].c==-1)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for(j=A[i].c;j!=-1;j=A[j].d){
      if(j==A[i].c)printf("%d",j);
      else printf(", %d",j);
    }
    printf("]\n");
  }
  return 0;
}