#include<stdio.h>
#include<string.h>
#define N 100000

typedef struct{

  int id;    //node
  int p;     //parent
  int d;     //depth
  int k;
  char type[20]; //type
  int c[20];

}node;

node no[N];

int main()
{

  int i,j,l=0,n;

  while(1)
    {
      scanf("%d",&n);
      if(n >= 1 && n <= N) break;
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d",&no[i].id,&no[i].k);
      for(j=0;j<no[i].k;j++) scanf("%d",&no[i].c[j]);
    }

  while(1)
    {
      if(no[l].k != 0)
	{
	  no[l].p = -1;
	  no[l].d = 0;
	  strcpy(no[l].type,"root");
	  break;
	}
      l++;
    }
  
  //parent
  for(i=l;i<n;i++)
    {
      //type
      if(no[i].k != 0)
	strcpy(no[i].type,"internal node");
      else
	strcpy(no[i].type,"leaf");

      
      //parent
      for(j=0;j<=i-1;j++)
	{
	  for(l=0;l<no[j].k;l++)
	      if(no[i].id == no[j].c[l]) no[i].p = no[j].id;
	}
    }

  for(i=l;i<n;i++)
    {
      if(no[i].p != -1) no[i].d = no[no[i].p].d + 1;
    }


  for(i=0;i<n;i++)
    {
      printf("node %d: parent = %d, depth = %d, %s, [",no[i].id,no[i].p,no[i].d,no[i].type);
      if(no[i].k == 0)
	  printf("]\n");
      else
	{
	  for(j=0;j<no[i].k-1;j++)
	    printf("%d, ",no[i].c[j]);
	  printf("%d]\n",no[i].c[j]);
	}
    }
  
  return 0;
}

