#include<stdio.h>

#define N 100000

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


int finddepth(int);

node T[N];

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

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

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

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