include<stdio.h>

#define N 100000

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


int finddepth(int);

node A[N];

int main()
{
  int pa, pr, x, i, j, n, k;

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

  for(i=0; i<n; i++)
    {
      scanf("%d%d", &pa, &k);
      if(k!=0)
    {
      scanf("%d", &x);
      A[pa].left = x;
      A[x].parent = pa;
      pr = x;
    }
      for(j=1; j<k; j++)
    {
      scanf("%d", &x);
      A[x].parent = pa;
      A[pr].right = x;
      pr = x;
    }
    }
  for(i=0; i<n; i++)
    {
      printf("node %d: parent = %d, depth = %d, ", i, A[i].parent, finddepth(i));
      if(A[i].parent == -1)
    {
      printf("root, ");
    }
      else if(A[i].left != -1)
    {
      printf("internal node, ");
    }
      else
    {
      printf("leaf, ");
    }
      printf("[");
      if(T[i].left != -1)
    {
      printf("%d", pr=A[i].left);
    }
      while(A[pr].right != -1)
    {
      printf(", %d", A[pr].right);
      pr = A[pr].right;
    }
      printf("]\n");
    }

  return 0;
}

int finddepth(int x)
{
  int c=0;
  while(A[x].parent >= 0)
    {
      c++;
      x = A[x].parent;
    }
  return c;
}