#include<stdio.h>
typedef struct{
  int number;
  int sa;//子の数
  int reach;
  int parent;
  int A[10000];
}node;

node B[10000];
int n;

int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<B[i].sa;j++){
      if(num==B[i].A[j]){
	r=i;
	return r;
      }
    }
  }
  return r;
}

int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}



int main(){
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&B[i].number);
    scanf("%d",&B[i].sa);
    for(j=0;j<B[i].sa;j++){
      scanf("%d",&B[i].A[j]);
    }
  }
  
  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",B[i].number,B[i].parent,B[i].reach);
    if(B[i].sa==0)printf("leaf, ");
    else if(B[i].parent==-1)printf("root, ");
    else printf("internal node, ");
    printf("[");
    for(j=0;j<B[i].sa;j++){
      if(j==0)printf("%d",B[i].A[j]);
      else printf(", %d",B[i].A[j]);
    }
     printf("]\n");

  }
  return 0;
}