#include <stdio.h>

typedef struct Node{
  int p, left, right;
} node;

node T[100000];

void new_node(int, int);

main(){
  int n, i, j, p = -1, c, data, before = 0;
scanf("%d", &n);
 for(i = 0; i < n; i++){
  new_node(-1, i); 
 }
  for(i = 0; i < n; i++){ 
    scanf("%d", &p);
    scanf("%d", &c);
    for(j = 0; j < c; j++){
      scanf("%d", &data);
      new_node(p, data);
      if(j == 0){
	T[p].left = data;
      }

      if(T[before].right == NULL){
	T[before].right = data;
      }

      before = data;
    }
    T[data].right = -1;
  }
  p =1;
   for(i = 0; i < n; i++){
    printf("node %d: ", i);
    printf("parent = %d, ", T[i].p);
    printf("depth = %d, ", T[i].p);
    if(T[i].left == NULL) printf("leaf");
    else printf("root");
    printf("[");
   
    for(j = 0; j < p; j++){ 
      if(j == 0 && T[i + j].left != -1){
	printf("%d", T[i + j].left);
	if(j != p - 1){
	  printf(", ");
	} 
      } else if(T[i + j].right != -1){
	printf("%d", T[i + j].right);
	if(j != p - 1){
	  printf(", ");
	} 
      }
    }
    printf("]");	
    printf("\n");
    p = T[i].p;
  }
  
}

void new_node(int p, int i){
  T[i].p = p; 
  T[i].right = NULL;
  T[i].left = NULL;
  return;
}