// Root Tree                                                                    
#include <stdio.h>
#include <stdlib.h>
#define N 10000
#define M 100

// node                                                                         
typedef struct node {
  int parent;
  int depth;
  int type;
  int degree;
  int c[M];
} NODE;

int main() {
  int n, id, sum = 0;
  int i, j;
  int child;
  NODE node[N];

  // input the number of node                                                   
  scanf("%d", &n);
  // initialize                                                                 
  for(i = 0; i < n; i++) {
      node[i].parent = -1;
      node[i].depth = 0;
      for(j = 0; j < M; j++) {
	node[i].c[j] = -1;
      }
  }

  // input each node information                                                
  for(i = 0; i < n; i++) {
    scanf("%d", &id); //id                                                      
    scanf("%d", &node[id].degree); // degree                                    
    for(j = 0; j < node[id].degree; j++) {
      scanf("%d", &node[id].c[j]); // children's node number                    
      sum += node[id].c[j];
    }
  }

  
  // search the each node's parent                                              
  for(i = 0; i < n; i++) {
    for(j = 0; j < node[i].degree; j++) {
      node[node[i].c[j]].parent = i;
      if(node[i].c[j] != -1) {
	node[node[i].c[j]].depth = node[i].depth + 1;
      }
    } 
  }

  // search node types
  for(i = 0; i < n; i++) {
    if(node[i].parent == -1) {
      node[i].type = 1;
    }
    else if(node[i].degree == 0) {
      node[i].type = 3;
    }
    else {
      node[i].type = 2;
    }
  }

  // output                                                                     
  for(i = 0; i < n; i++) {
    printf("node %d: ", i);
    printf("parent = %d, ", node[i].parent);
    printf("depth = %d, ", node[i].depth);
    switch(node[i].type) {
    case 1:
      printf("root, ");
      break;
    case 2:
      printf("internal node, ");
      break;
    default:
      printf("leaf, ");
      break;
    }

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

  return 0;
}


