#include <stdio.h>
#define N 100000
/*
If N is more than 4000000, the program will crash (segmetation fault).
 */

/*
How to test
% diff <(./a.out < b1in.txt) <(cat b1out.txt) 
$ ./a.out < ain.txt 2>erra.txt

  for( i=0 ; i < n ; i++){
    fprintf(stderr, "%d: C2[%d] = %c%c \n" ,__LINE__ ,i ,C2[i].suit ,C2[i].value );
  }

 */

typedef struct{
  int id;
  int k;
  int c[100];
  int parent;
} node_t ;

node_t a[N] = {0};

int depth(const int n, const int start){ 
  int cnt=0;
  int i, j;
  int id = start;

  while( a[id].parent!=-1){
    cnt++;
    id = a[id].parent;
  }
  return cnt;
}

// 0:root 1:internal node 2:leaf
int type(const int id){
  if(a[id].parent == -1){
    return 0;
  }else if(a[id].k == 0 ){
    return 2;
  }
  return 1;
}

int main(){
  int n, i, j;

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%d%d" ,&(a[i].id) ,&(a[i].k) );
    for( j = 0; j < a[i].k ; j++){
      scanf("%d" ,&(a[i].c[j]) );      
    }
  }

  for(i=0; i < n ; i++){
    a[i].parent = -1;
  }
  for(i=0; i < n ; i++ ){
    for( j=0 ; j < a[i].k ; j++){
      a[a[i].c[j]].parent = a[i].id;
    }
  }

  for( i=0 ; i<n ; i++){
    printf("node %d: parent = %d, depth = %d, " 
	   ,a[i].id ,a[i].parent ,depth(n,i) );
    int ty = type(i);
    if(ty==0){
      printf("root, ");
    }else if( ty==1 ){
      printf("internal node, ");
    }else{
      printf("leaf, ");
    }

    printf("[");
    for(j=0 ; j < a[i].k ; j++){
      printf("%d" ,a[i].c[j]);
      if( j != (a[i].k-1) ){
	printf(", ");
      }
    }
    printf("]");
    printf("\n");
  }

  return 0; // Don't forget return 0
}