#include <stdio.h>
#define N 100000

typedef struct{

  int id;
  int parent;
  int left;
  int right;

} Node;

int n;
Node in[N];

void init();
int depth(int);
int type(int);

int main(){
  int i, j, id2, a, d, k, temp;
  
  init();
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%d %d", &id2, &d);
    in[i].id = id2;
    
    for(j = 0; j < d; j++){
      scanf("%d",&a);
      
      if(j == 0){
	in[id2].left = a;
      } else {
	in[temp].right = a;
      } 

      temp = a;
      in[a].parent = id2;

    }

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

    printf("[");
    
    k = in[i].left;

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

	k=in[k].right;

      }
    }

    printf("]\n");
    
  }
  
  return 0;
}


void init(){
  int i;

  for(i = 0; i < N; i++){
    in[i].id = -1;
    in[i].parent = -1;
    in[i].left = -1;
    in[i].right = -1;
  }

}



int depth(int num){
  int i;

  for(i = 0; in[num].parent != -1; i++){
    num = in[num].parent;
  }

  return i;

}


int type(int num){

  if(in[num].parent == -1){
    return 0;
  }

  if(in[num].left == -1){
    return 1;
  }

  return 2;

}