#include <stdio.h>

#define MAX 100000

int getDepth(int);

struct tree {
  int parent;
  int left;
  int right;
};

struct tree array[MAX];

int main(){

  int n, i, j, id, degree, child, left, right;

  scanf("%d", &n);

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

  for( i=0; i<n; i++){
    scanf("%d%d", &id, &degree);
    for( j=0; j<degree; j++){
      scanf("%d", &child);
      if( j == 0 ){
	array[id].left = child;
      }
      else array[left].right = child;
      left = child;
      array[child].parent = id;
    }
  }

  for( i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, array[i].parent, getDepth(i));
    if( array[i].parent == -1 ) printf("root, ");
    else if( array[i].left == -1 ) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    child = array[i].left;
    while(child != -1){
      if( child == array[i].left ){
	printf("%d", child);
      }
      else printf(", %d", child);
      child = array[child].right;
    }
    printf("]\n");
  }

  return 0;
}

int getDepth(int u){
  int d=0;

  while( array[u].parent != -1 ){
    u = array[u].parent;
    d++;
  }

  return d;
}