#include<stdio.h>
#define LEN 100001
#define NILL -1

int main()
{
  int n;
  int P[LEN], L[LEN],R[LEN];
  int id, child;
  int i, j, k, m;  

  //initialization
  for(i=0; i<LEN; i++)
    {
      P[i]=NILL;
      L[i]=NILL;
      R[i]=NILL;
    }

  //make node
  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      scanf("%d %d", &id, &k);
      for(j=0; j<k; j++)
	{
	  scanf("%d", &child);
	  P[child]=id;
	  if(j==0)L[id]=child;
	  else R[m]=child;
	  m=child;
	}
    }

  //print
  //for(i=0; i<n; i++)printf("n%d p%d L%d R%d\n", i, P[i], L[i], R[i]);
  for(i=0; i<n; i++)
    {
      //node
      printf("node %d: ", i);

      //parent
      printf("parent = %d, ", P[i]);

      //depth
      for(j=P[i], k=0; j!=NILL; j=P[j], k++);
      printf("depth = %d, ", k);

      //type
      if(P[i]==NILL)printf("root, ");
      else if(P[i]!=NILL && L[i]!=NILL)printf("internal node, ");
      else printf("leaf, ");

      //children
      k=0;
      printf("[");
      for(j=L[i]; j!=NILL; j=R[j])
	{
	  printf("%d, ", j);
	  k=1;
	}
      if(k!=0)printf("\b\b]\n");
      else printf("]\n");
    }
return 0;
}