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

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

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

vertex V[100000];
int D[100000];
int n,degree[10000];
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);
    }

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

int FindDepth(int i)
{
  int d = 0,u = 0;
  while(1){
    if(V[i].parent == NIL)break;
    d++;
    i = V[i].parent;
  }

  return d;
}


void output(int p)
{
  int i,j,c;

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

  
  c = V[p].left;
  if(c != NIL)
    {
      while(1)
	{
	  if(V[c].right == NIL)
	    {
	      printf("%d",c);
	      break;
	    }
	  else{
	    printf("%d, ",c);
	    c = V[c].right;
	  }
	}
    }
 
      
      
    
  printf("]\n");

}