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

typedef struct {
  int parent;
  int left; //左の子
  int right; //右の兄弟
  int depth;
} node;


void initializNodeArray(node* a, int n) {
  int i;

  for( i=0; i<n; i++) {
    a[i].parent = -1;
    a[i].left = -1;
    a[i].right = -1;
  }

}


void treeWalkForDepth(node* a, int root, int depth) {
  a[root].depth = depth;
  
  if( a[root].left != -1 ) {
    treeWalkForDepth( a, a[root].left, depth+1 ); 
  }
  if( a[root].right != -1) {
    treeWalkForDepth( a, a[root].right, depth );
  }

}


int rootNodeSearch(node* a, int n) {
  int i;

  for( i=0; i<n; i++) {
    if( a[i].parent == -1 ) {
      return i;
    }
  }

}


main() {

  int n, k, id, children, parent;
  node* a;
  
  int i, j;

  scanf("%d", &n);

  a = (node*)malloc( sizeof(node) * n );

  initializNodeArray( a, n);

  for( i=0; i<n; i++) {
    scanf("%d", &id);

    scanf("%d", &k);

    for( j=0; j<k; j++) {
      if( j==0 ) {
	scanf("%d", &a[id].left);
	children = a[id].left;
	a[children].parent = id;
      }else {
	scanf("%d", &a[children].right);
	children = a[children].right;
	a[children].parent = id;
      }
    }

  }
  treeWalkForDepth( a, rootNodeSearch( a, n), 0);
  
  for( i=0; i<n; i++) {
    printf("node %d: parent = %d, depth = %d, ", i, a[i].parent, a[i].depth);

    if( a[i].parent == -1 ) {
      printf("root, ");
    }else if( a[i].left == -1 ) {
      printf("leaf, ");
    }else {
      printf("internal node, ");
    }

    printf("[");
    if( a[i].left != -1){
      printf("%d",a[i].left);
      children = a[i].left;

      while(1) {
	if( a[children].right != -1) {
	  printf(", %d", a[children].right);
	  children = a[children].right;
	}else {
	  break;
	}
      }
    }
    printf("]");
      

    printf("\n");

  }

}
  