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

typedef struct {
  int p;
  int q;
  int *z;
}Node;

int rec(Node*,int,int);

int main(){
  int num,i,j,k,l;
  Node node[N];

  scanf("%d",&num);

  for( i = 0 ; i < num ; i++ ) {
    node[i].p = -1;
  }

  for( i = 0 ; i < num ; i++ ) {
    scanf("%d",&l);
    scanf("%d",&node[l].q);
    node[l].z = (int *) malloc(sizeof(int) * node[l].q);

    for( j = 0 ; j < node[l].q ; j++ ) {
      scanf("%d",&node[l].z[j]);
      node[node[l].z[j]].p = l;
    }
  }
 
  for( i = 0 ; i < num ; i++ ) {
    printf("node %d: parent = %d, ",i,node[i].p);
    printf("depth = %d, ",rec(node,i,0));

    if( node[i].p == -1 ) printf("root, [");
    else if( node[i].q == 0 ) printf("leaf, [");
    else printf("internal node, [");

    for( j = 0 ; j < node[i].q ; j++ ) {
      printf("%d",node[i].z[j]);
      if(j+1 < node[i].q) printf(", ");
    }
    printf("]\n");
  }
  return 0;
}

int rec(Node *node,int num,int suu){
  if(node[num].p == -1) return suu;
  suu++;
  suu = rec(node,node[num].p,suu);

  return suu;
}