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

typedef struct s{
  int key;
  int *left;
  int **right;
  int *parent;
}Node;

Node root;
Node *T = &root;
int depth=0;

int main(void){
  int i,j,n,k,d;

  // input 
  scanf("%d",&n);

  while(T->left != 0){
    scanf("%d %d ",&T->left,&k); 

    if(k == 0){
      T[i].left = NULL;
      T[i].right = (int *)malloc(sizeof(int));
      T[i].right = NULL;
      continue;
    }

    T[i].right = (int *)malloc(sizeof(int) * k-1);

    scanf("%d ",&T[i].left);

    T[T[i].left].parent = T[i].key;

    if(i == 0){
      T[i].parent = -1;
      continue;
    }

    for(j=0; j<k-1; j++){
      scanf("%d ",&T[i].right[j]);
      T[T[i].right[j]].parent = T[i].key;
    }

  }

  // output
  for(i=0; i<n; i++){
    d = calcDepth(&T[i]);
    printf("node %d: parent = %d, depth = %d, ",T[i].key, T[i].parent, d);

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

    if(k == 0) printf("[]\n");
    else{
      printf("[%d,",T[i].left);
      for(j=0; j<k-1; j++){
	if(j == k-1) printf("%d",T[i].right[j]);
	else printf("%d, ",T[i].right[j]);
      }
      printf("]\n");
    }

  }

  for(i=0; i<n; i++) free(T[i].right);
  free(T);

  return 0;
}