#include <stdio.h>
#include <string.h>

#define N 131072

typedef struct {
  int parent;
  int child;
  int sibling;
  int depth;
} node_t;

void dfs(node_t *array, int id, int d) {
  int child;

  if (id == -1)
    return;
  array[id].depth = d;
  for (child = array[id].child; child != -1; child = array[child].sibling)
    dfs(array, child, d+1);
}

int main(void) {
  int i, j, n, left, pid, cid, k;
  char *type;
  node_t array[N];
  memset(array, -1, sizeof(array));

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &pid);
    scanf("%d", &k);
    for (j = 0; j < k; j++) {
      scanf("%d", &cid);
      array[cid].parent = pid;
      if (!j)
	array[pid].child = cid;
      else
	array[left].sibling = cid;
      left = cid;
    }
  }

  // calulate depths
  for (i = 0; i < n; i++) {
    if (array[i].parent == -1) {
      dfs(array, i, 0);
      break;
    }
  }
  
  for (i = 0; i < n; i++) {
    // determination a node type
    if (array[i].parent == -1)
      type = "root";
    else if (array[i].child == -1)
      type = "leaf";
    else
      type = "internal node";
    
    printf("node %d: parent = %d, depth = %d, %s, ["
  	   , i, array[i].parent, array[i].depth, type);

    // print child nodes
    int id = i;
    for (k = 0; id != -1; k++) {
      if (!k && array[id].child != -1) {
	printf("%d", array[id].child);
	id = array[id].child;
      }
      else if (k && array[id].sibling != -1){
   	printf(", ");
      	printf("%d", array[id].sibling);
	id = array[id].sibling;
      }
      else
	break;
    }
    printf("]\n");
  }

  return 0;
}