#include <stdio.h>
#include <stdlib.h>


typedef struct{
  int parent;
  int cnum;
  int *child;
} Node;

int main(){
  int n;
  int N;
  int num;
  Node A[100000];
  int i,j;
  int jag;
  int depth;
  
  
  
  scanf("%d",&n);
  for(i=0;i<n;i++) A[i].parent=-1;
  for(i=0;i<n;i++){
    scanf("%d",&num);
    scanf("%d",&A[num].cnum);
    A[num].child=(int *)malloc(A[num].cnum*sizeof(int));
    for(j=0;j<A[num].cnum;j++){
      scanf("%d",&A[num].child[j]);
      A[A[num].child[j]].parent=num;
    }
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,A[i].parent);
    jag=A[i].parent;
    depth=0;
    while(1){
      if(jag==-1){
	printf("depth = %d, ",depth);
	break;
      }
      else{
	depth++;
	jag=A[jag].parent;
      }
    }
    if(depth==0) printf("root, [");
    else if(A[i].cnum!=0) printf("internal node, [");
    else printf("leaf, [");
    if(A[i].cnum!=0){
      for(j=1;j<A[i].cnum;j++) printf("%d, ",A[i].child[j-1]);
      printf("%d",A[i].child[j-1]);
    }
    printf("]\n");
  }
  return 0;
}

