#include<stdio.h>
#include<stdlib.h>
#define N 1000

typedef struct{
  int parent;
  int left;
  int right;
}Node;

int main(){
  int point,number,i,j,a,b,n,deep=0,place,count,k;
  int *Deep;
  int num[N];
  Node *Tree;

  scanf("%d",&n);
  Tree =  ( Node * )malloc( sizeof(Node) * n );
  Deep = ( int * )malloc( sizeof(int) * n );
  // Tree を初期化する
  for( i = 0 ; i < n ; i++ ){  
    Tree[i].parent = -1;
    Tree[i].left = -1;
    Tree[i].right = -1;
  }

  for( i = 0; i < n ; i++ ){
    scanf("%d %d",&point,&number);
    for( j = 0 ; j < number ; j++ ){
      scanf("%d",&a);
      if( i == 0 ){
	num[j] = a;
	count++;
      } 
      Tree[a].parent = point;

      if( j == 0 ) Tree[point].left = a;
      else Tree[b].right = a;

      b = a;
    }
  }

  for( i = 0 ; i < n ; i++ ){
    place = i;
    while( Tree[i].parent != -1 ){
      deep++;
      place = Tree[place].parent;
    }
    Deep[i] = deep;
    deep = 0;
  }

  for( i = 0 ; i < n ; i++ ){
    printf("node %d: parent = %d, depth = %d, ",i,Tree[i].parent,Deep[i]);
    if( Tree[i].parent == -1 ){
      printf("root, [");
      for( k = 0 ; k < count-1 ; k++ ) printf("%d,",num[k]);
      printf("%d]",num[count]);
    }
    else if( Tree[i].left == -1 ) printf("leaf, []");
    else{
      printf("internal node, [%d, ",Tree[i].left);
      i = Tree[i].left;
      if( Tree[i].right != -1 ) printf(", ");
      while( Tree[i].right == -1 ){
	printf("%d",Tree[i].right);
	i = Tree[i].right;
	if( Tree[i].right != -1 ) printf(", ");
      }
    }
    printf("]\n");
  }
  return 0;
} 