#include <stdio.h>
#include <stdlib.h>

#define NIL -1
#define RECO -2

typedef struct Node
{
  int parent;
  int firstchild;
  int rightsibling;
}Node;

int CountDepth(Node*,int);

int main()
{
  int a,b,c,list,nodeID, nextsibling=0;
  scanf("%d", &a);
  
  Node* TreeList =(Node*)malloc(a*sizeof(Node));
  
  for(int i=0;i<a;i++)
    { TreeList[i].parent=NIL;TreeList[i].firstchild=RECO;TreeList[i].rightsibling=RECO;}
  for(int i=0;i<a;i++){
      scanf("%d %d", &nodeID, &b);
      for(int j=0;j<b;j++)
        {
	  scanf("%d", &list);
	  
	  TreeList[list].parent = nodeID;
	  
	  if(j==0){TreeList[nodeID].firstchild=list;}
	  else
            {
	      TreeList[nextsibling].rightsibling=list;
            }
	  nextsibling = list;
        }
    }
  
  for(int i=0;i<a;i++){
      printf("node %d: parent = %d, depth = %d,", i, TreeList[i].parent, CountDepth(TreeList, i));
      if(CountDepth(TreeList, i)==0){printf(" root, [");}
      else if(TreeList[i].firstchild==RECO){printf(" leaf, [");}
      else{printf(" internal node, [");}
      if(TreeList[i].firstchild!=RECO)
        {
	  printf("%d", TreeList[i].firstchild);
	  c = TreeList[i].firstchild;
	  while(TreeList[c].rightsibling!=RECO)
            {
	      printf(", %d", TreeList[c].rightsibling);
	      c = TreeList[c].rightsibling;
            }
        }
      
      printf("]\n");
        
    }
  free(TreeList);
  
  return 0;
}

int CountDepth(Node* List, int ID)
{
  int s=0;
  while(List[ID].parent!=NIL)
    {
      s++;
      ID = List[ID].parent;
    }
  return s;
}

