#include<stdio.h>
#define NIL -1

int FindDepth (int,int );
void output(int );

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

vertex V[20];
int D[20];
int n,degree[20];
int childsoe,maesoe;
main()
{
  int a,i,j;
 
  scanf("%d",&n);

  /*????????¢?????????????????§?§?????????????????????¨??????NIL?????£??\??????*/
  for(i=0;i<n;i++)
    {
      V[i].parent = V[i].left = V[i].right = NIL;
    }

  for(i=0;i<n;i++)
    {
      scanf("%d",&a);/*vertex number*/
      scanf("%d",&degree[i]);/*degree*/
    
      for(j=0;j<degree[i];j++)
	{
	  scanf("%d",&childsoe);
	  if(j == 0)
	    {
	      V[a].left = childsoe;
	      V[childsoe].parent = a;
	      maesoe = childsoe;  /*????????????*/
	    }
	  else {
	    V[maesoe].right = childsoe;/*??????childsoe????????£??????*/
	    V[childsoe].parent = a;
	    maesoe = childsoe; /*????????????????????£??????right???NIL????????£?????????*/
	  }

	}/*degree??¨???*/
      
    }/*????????§?????????????????????????????£??\?????????*/

  for(i=0;i<n;i++)
    {
      D[i] = FindDepth(i,0);
    }

  for(i=0;i<n;i++)
    {
      output(i);/*????????????*/
    }
  return 0;
}

int FindDepth(int i,int cou)
{

      if(V[i].parent == 0 || V[i].parent == NIL )
	{
	  cou++;
	  return cou;
	}
      else
	{
	  cou++;
	  FindDepth(V[i].parent,cou); /*?????°*/
	}
      
}


void output(int p)
{
  int i,j,count=0;

  printf("node %d: parent = %d, depth = %d, ",p,V[p].parent,D[p]);
  if(V[p].left== NIL && p!=0)
    {
      printf("leaf, ");
    }
  else if(p==0)
    {
      printf("root, ");
    }
  else printf("internal node, ");

  printf("[");

  for(i=0;i<n;i++)
    {
      if(count>=1)continue;
      if(V[i].parent == p)
	{
	  
	  printf("%d, ",V[p].left);
	  maesoe = V[p].left;
	  while(1)
	    {

	      childsoe = V[maesoe].right;
	     
	      if(childsoe==NIL)break;
	      printf("%d",childsoe);
	      count++;
	      if(count!=degree[p]-1)printf(", ");
	      maesoe = childsoe;
	    }
	}	  
	  
      
      
    }
  printf("]\n");

}