#include <stdio.h>

#define MAX 100000
#define NIL -1

typedef struct
{
  int parent;
  int left;
  int right;
} TREE;

void SetDepth(TREE[], int, int[], int);
void PrintChildren(TREE[], int, int[]);
int GetRoot(TREE[], int);

int main()
{
  TREE tree[MAX];
  int depth[MAX];
  int n, id, k, c, l, root;
  int i, j;

  for (i = 0; i < MAX; i++)
  {
    depth[i] = 0;
    tree[i].parent = NIL;
    tree[i].left = NIL;
    tree[i].right = NIL;
  }

  scanf("%d", &n);

  for (i = 0; i < n; i++)
  {
    scanf("%d %d", &id, &k);

    for (j = 0; j < k; j++)
    {
      scanf("%d", &c);

      if (j == 0)
        tree[id].left = c;

      else
        tree[l].right = c;

      l = c;
      tree[l].parent = id;
    }
  }

  root = GetRoot(tree, 0);
  SetDepth(tree, root, depth, 0);

  for (i = 0; i < n; i++)
    PrintChildren(tree, i, depth);

  return 0;
}

void SetDepth(TREE tree[], int u, int depth[], int p)
{
  depth[u] = p;

  if (tree[u].right != NIL)
    SetDepth(tree, tree[u].right, depth, p);

  if (tree[u].left != NIL)
    SetDepth(tree, tree[u].left, depth, p + 1);
}

int GetRoot(TREE tree[], int u)
{
  while (tree[u].parent != NIL){
    u = tree[u].parent;
  }

  return u;
}

void PrintChildren(TREE tree[], int u, int depth[])
{
  int c;

  c = tree[u].left;

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

  if (tree[u].parent == NIL)
    printf("root, ");

  else if (tree[u].left == NIL)
    printf("leaf, ");

  else
    printf("internal node, ");

  printf("[");

  while (c != NIL)
  {

    if (tree[c].right == NIL)
    {
      printf("%d", c);
      break;
    }

    else
    printf("%d, ",c);

    c = tree[c].right;
  }

  printf("]\n");
}

