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

#define ROOT 0
#define INTERNAL 1
#define LEAF 2

struct node {
  int id;
  int k;
  struct node *parent;
  int depth;
  int type;
  int *child_id;
  struct node **child;
};

struct node *tree;
int n;

void set_parameter(struct node *p);

int main(int argc, char *argv[])
{
  int i, j, border, num, ch;
  struct node *tmp;
  
  scanf("%d", &n);

  tree = (struct node *)malloc(sizeof(struct node) * n);

  for (i = 0; i < n; i++) {
    scanf("%d", &num);
    tree[num].id = num;
    scanf("%d", &(tree[num].k));
    if (tree[num].k != 0) {
      tree[num].child_id = (int *)malloc(sizeof(int) * (tree[num].k));
      tree[num].child = (struct node **)malloc(sizeof(struct node *) * (tree[num].k));
      for (j = 0; j < tree[num].k; j++) {
	scanf("%d", &(tree[num].child_id[j]));
      }
    } else {
      tree[num].child_id = NULL;
      tree[num].child = NULL;
    }
    tree[num].parent = NULL;
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < tree[i].k; j++) {
      ch = tree[i].child_id[j];
      tree[ch].parent = &tree[i];
      tree[i].child[j] = &tree[ch];
    }
  }

  for (i = 0; i < n; i++) {
    if (tree[i].parent == NULL) break;
  }
  set_parameter(&tree[i]);

  for (i = 0; i < n; i++) {
    printf("node %d: ", tree[i].id);
    
    if (tree[i].parent == NULL) printf("parent = -1, ");
    else printf("parent = %d, ", tree[i].parent->id);
    
    printf("depth = %d, ", tree[i].depth);
    
    if (tree[i].type == ROOT) printf("root, ");
    else if (tree[i].type == INTERNAL) printf("internal node, ");
    else printf("leaf, ");

    printf("[");
    for (j = 0; j < tree[i].k; j++) {
      if (j != tree[i].k - 1) printf("%d, ", tree[i].child[j]->id);
      else printf("%d", tree[i].child[j]->id);
    }
    printf("]\n");
  }

  return 0;
}

void set_parameter(struct node *p)
{
  int i;

  if (p->parent == NULL) {
    p->depth = 0;
    p->type = ROOT;
  } else {
    p->depth = p->parent->depth + 1;
    if (p->k == 0) p->type = LEAF;
    else p->type = INTERNAL;
  }

  for (i = 0; i < p->k; i++) set_parameter(p->child[i]);
}