#include<stdio.h>

typedef struct node{

  int num;
  int depth;
  int parent;
  int br;
  int child;

}Node;

void nodegene( Node*);

void nodegene( Node* node){

  node -> depth = 0;
  node -> child = -1;
  node -> br = -1;
  node -> parent = -1;

}


int main(){

  int i, j, m, n, l, nod, d, degree,br;
  Node node[100001];
  Node c;
  scanf("%d",&m);

  for( i =0; i < m; i++)nodegene(&node[i]);

  for( i = 0; i < m; i++){

    scanf("%d%d", &n, &nod);

    for( j = 0; j < nod; j++){

      scanf("%d", &degree);

      if( node[n].child == -1){
	node[n].child = degree;
	node[degree].parent = n;
      }
      else if(node[n].child != -1){
	l = node[n].child;
	while( node[l].br != -1) l = node[l].br;

	node[l].br = degree;
	node[degree].parent = n;
      }
      node[degree].depth = node[n].depth + 1;
    }
  }

  for( i = 0; i < m; i++){

    printf("node %d: parent = %d, depth = %d, ", i, node[i].parent, node[i].depth);

    if(node[i].child == -1 && node[i].parent != -1)
      printf("leaf, ");
    else if(node[i].parent == -1 && node[i].child!= -1)
      printf("root, " );
    else 
      printf("internal node, " );

    printf("[");

    if(node[i].child != -1){

      printf("%d",node[i].child);

      br = node[i].child;

      while(1){
	if(node[br].br == -1)
	  break;
	printf(", %d",node[br].br);
	br = node[br].br;
      }
    }

    printf("]\n");
  }
  return 0;
}