#include<stdio.h>
#define ROOT -1
#define N 100000

typedef struct node{
  int pa;
  int left; 
  int right;
}NODE;

 NODE T[N];


int num, h=0;
int  De[N];

int depth(int);
void print(int);


/*main 関数*/
main(){

  int  i,j,t;
  int  degree, num2, elem;


  scanf("%d", &num);
  /*初期化*/
  for ( i = 0; i < num; i++ ){
    T[i].pa = ROOT;
    T[i].left = ROOT;
    T[i].right = ROOT;
  }


  for ( i = 0; i < num; i++ ){
    scanf("%d %d", &num2, &degree);

    for ( j = 0; j < degree; j++ ){
      scanf("%d", &elem);


      if ( j == 0 ){
	T[num2].left = elem;
      }
      else {
	
	T[t].right = elem;
      }
      
      t = elem;
      /*親指定*/
      T[t].pa = num2;
    }
  }
  
  for ( i = 0; i < num; i++ ){ De[i] = depth(i); }

  /*表示*/
  for ( i = 0; i < num; i++ ){

    /*関数の呼出*/
    print(i);
  }
  return 0;
}

void print(int a){
  int i;
  int c;


  printf("node %d: ", a);
  printf("parent = %d, ", T[a].pa);
  printf("depth = %d, ", De[a]);

  if ( T[a].pa == ROOT ) printf("root, ");

  else if ( T[a].left == ROOT ) printf("leaf, ");

  else printf("internal node, ");

  printf("[");


  for(i = 0, c = T[a].left; c != ROOT; i++, c = T[c].right){
    if (i!=0){
 printf(", ");
    }

    printf("%d", c);
  }
  printf("]\n");
}

/*深さの計算*/
int depth(int a){
  int cnt=0;

  while(T[a].pa != ROOT){
    cnt++;
    a = T[a].pa;
   
  }
  return cnt;
}