#include <stdio.h>

struct Node{
  int parent;
  int left;
  int right;
};

void setup(struct Node node[], int n) {
  for (int i = 0; i < n; i++) {
    node[i].parent = -1;
    node[i].left = -1;
    node[i].right = -1;
  }
}

void input(struct Node node[], int n) {
  int id, k, c1, c2;

  for (int i = 0; i < n; i++) {
    scanf("%d%d", &id, &k);
    for(int j = 0; j < k; j++) {
      if (j == 0) {
	scanf("%d", &c1);
	node[c1].parent = id;
	node[id].left = c1;
      }
      else {
	scanf("%d", &c2);
	node[c1].right = c2;
	node[c2].parent = id;
	c1 = c2;
      }
    }
  }
}

int search_depth(struct Node node[], int id) {
  id = node[id].parent;
  if (id != -1) {
    return search_depth(node, id) + 1;
  }
  else
    return 0;
}

void print_type(struct Node node[], int id) {
  if (node[id].parent == -1)
    printf("root, ");
  else if (node[id].left == -1)
    printf("leaf, ");
  else
    printf("internal node, ");
}

void print_clist(struct Node node[], int id) {
  id = node[id].left;
  printf("[");
  while (id != -1) {
    if (node[id].right != -1)
      printf("%d, ", id);
    else
      printf("%d", id);
    id = node[id].right;
  }
  printf("]");
}

void output(struct Node node[], int n) {
  int depth;
  for (int i = 0; i < n; i++) {
    printf("node %d: parent = %d, ", i, node[i].parent);
    printf("depth = %d, ", search_depth(node, i));
    print_type(node, i);
    print_clist(node, i);
    printf("\n");
  }
}

int main(void) {
  int n;

  struct Node node[100000];
  
  scanf("%d", &n);

  setup(node, n);
  input(node, n);

  output(node, n);

  return 0;
}

