#include<stdio.h>

typedef struct{
  int id;
  int degree;
  int c[100];
  int parent;
  int depth;
}Tree;

main(){
  int i,j,k,g,h,x,y,count;
  Tree node[100];
  scanf("%d",&g);
  for(i=0;i<g;i++){
    scanf(" %d",&h);
    node[h].id = h;
    scanf("%d",&node[h].degree);
    if(node[h].degree>0){
    for(j=0;j<node[h].degree;j++)scanf("%d",&node[h].c[j]);
    }}
  

   for(i=0;i<g;i++){
    for(j=0;j<g;j++){
      count=0;
      for(k=0;k<node[j].degree;k++){
	if(node[i].id==node[j].c[k]){
	  node[i].parent=node[j].id;
          count++;
	  break;
	}}
      if(count>0)break;
      else node[i].parent = -1;
    }}
   
  for(i=0;i<g;i++){
    node[i].depth=0;
    if(node[i].parent==-1)continue;
    if(node[i].parent>=0)node[i].depth++;
    x=node[i].parent;
    while(1){
      if(node[x].parent>=0){
	node[i].depth++;
	x = node[x].parent;
      }
      else  break;
    }
  }


  for(i=0;i<g;i++){
    printf("node %d: parent = %d, depth = %d, ",node[i].id,node[i].parent,node[i].depth);
    if(node[i].depth==0)printf("root,");
    else if(node[i].depth>=0 && node[i].degree>0)printf("internal node,");
    else if(node[i].degree==0){
      printf("leaf, []\n");
      continue;
    }
    printf(" [");
    for(j=0;j<node[i].degree;j++){
      printf("%d",node[i].c[j]);
      if(j>=0 && j<node[i].degree-1)printf(", ");
    }
    printf("]\n");
  }
  return 0;
}