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

int depth[100000];

struct node {
  int parent, child, sibling;
};
struct node tree[100000];

void showInfo(int id) {
  char type[20];
  if(tree[id].parent == -1)
    strcpy(type, "root");
  else if(tree[id].child != -1)
    strcpy(type, "internal node");
  else
    strcpy(type, "leaf");

  printf("node %d: parent = %d, depth = %d, %s, ", id, tree[id].parent, depth[id], type);

  printf("[");
  if(tree[id].child != -1) {
    id = tree[id].child;
    while(tree[id].sibling != -1) {
      printf("%d ,", id);
      id = tree[id].sibling;
    }
    printf("%d", id);
  }
  printf("]\n");
}

void setDepth(int id, int d) {
  depth[id] = d;
  if(tree[id].child != -1)
    setDepth(tree[id].child, d + 1);
  if(tree[id].sibling != -1)
    setDepth(tree[id].sibling, d);
  if(tree[id].child == -1)
    return;
}

int main() {
  int i, j, n, id, k, root, c[5000];

  scanf("%d", &n);
  for(i = 0;i < n;i++) {
    tree[i].sibling = -1;
    tree[i].parent = -1;
    tree[i].child = -1;
  }

  for(i = 0;i < n;i++) {
    scanf("%d", &id);
    scanf("%d", &k);
    if(k != 0) {
      for(j = 0;j < k;j++) {
        scanf("%d", &c[j]);
        tree[c[j]].parent = id;
        if(j > 0)
          tree[c[j - 1]].sibling = c[j];
      }
      tree[id].child = c[0];
    }
  }

  for(i = 0;i < n;i++)
    if(tree[i].parent == -1)
      root = i;

  setDepth(root, 0);

  for(i = 0;i < n;i++)
    showInfo(i);

  return 0;
}

