#include <stdio.h>
#define n 100000


typedef struct{
  int node;
  int demention;
  int parent;
  int depth;
  int argment[];
} tree;

int main()
{
  int i, j, nn, d=0;
  tree treenode[n];
  
  scanf("%d", &nn);
  
  for(i=0;i<nn;i++){
    scanf("%d%d", &treenode[i].node, &d);
    treenode[i].demention = d;

    treenode[0].parent = -1;
    treenode[0].depth = 0;
   
    if(d>=1){
      treenode[i].depth = treenode[treenode[i].parent].depth + 1;
      for(j=0;j<d;j++){
	scanf("%d", &treenode[i].argment[j]);
	treenode[treenode[i].argment[j]].parent = treenode[i].node;
      }
    }else if(i!=0)
      treenode[i].depth = treenode[treenode[i].parent].depth + 1;
  } 

  for(i=0;i<nn;i++){
    printf("node %d: parent = %d, depth = %d, ", i, treenode[i].parent, treenode[i].depth);
    if(treenode[i].depth == 0) {
      printf("root, [");
      for(j=0;j<treenode[i].demention;j++){
	printf("%d", treenode[i].argment[j]);
	if(j!=(treenode[i].demention-1)) printf(", ");
      }
      printf("]");
    }else if(treenode[i].demention > 0) {
      printf("internal node, [");
      for(j=0;j<treenode[i].demention;j++){
	printf("%d", treenode[i].argment[j]);
	if(j!=(treenode[i].demention-1)) printf(", ");
      }
      printf("]");
    }else printf("leaf, []");
    printf("\n");
  }

  return 0;
}