#include<stdio.h>
#define N 100000
#define NIL -1
typedef struct{
  int parent;
  int left;
  int right;
}node;
node Tree[N];
int main()
{
  int i,id,j,n,kosuu,c[N],depth=0,num=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      Tree[i].parent=Tree[i].left=Tree[i].right=NIL;
    }
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&id,&kosuu);
      for(j=0;j<kosuu;j++)
	{
	  scanf("%d",&c[j]);
	  if(j==0)
	    {
	      Tree[c[0]].parent=id;
	      Tree[id].left = c[0];
	    }
	  else
	    {
	      Tree[c[j]].parent = id;
	      Tree[c[j-1]].right=c[j];
	    }
	}
    }
  
  for(i=0;i<n;i++)
    {
      printf("node %d: parent = %d, ",i,Tree[i].parent);
      num=i;
      while(Tree[num].parent!=NIL)
	{
	  depth++;
	  num=Tree[num].parent;
	}
      printf("depth = %d,",depth);
      depth=0;
      if(Tree[i].parent==NIL  && Tree[i].left==NIL)
	{
	  printf(" root, []\n");
	}
      else if(Tree[i].parent==NIL && Tree[i].left!=NIL)
	{
	  printf(" root, [%d",Tree[i].left);
	  for(j=Tree[Tree[i].left].right;j!=NIL;j=Tree[j].right)
	    {
	      printf(", %d",j);
	    }
	  printf("]\n");
	}
      else if(Tree[i].left!=NIL)
	{
	  printf(" internal node, [%d",Tree[i].left);
	  for(j=Tree[Tree[i].left].right;j!=NIL;j=Tree[j].right)
	    {
	      printf(", %d",j);
	    }
	  printf("]\n");
	}

      else
	{
	  printf(" leaf, []\n");
	}
    }
  return 0;
}


  

