#include<stdio.h>

typedef struct {
  int id;
  int parent;        //親
  int child;         //子
  int right_sibling; //兄弟(右隣)
  int depth;         //深さ
}Node;

Node node[100000]; 
int c[100000];

main()
{
  int n, i, j, id, degree;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++)
    {
      node[i].parent = -1;
      node[i].child = -1;
      node[i].right_sibling = -1;
      node[i].depth = 0;
    }
  
  for(i=0; i<n; i++)
    {
      scanf("%d %d", &id, &degree);
      node[id].id = id;
      for(j=0; j<degree; j++)
        {
          scanf("%d", &c[j]);
          if(j == 0)
            {
              node[id].child = c[j];
            }
          else if(j != 0)
            {
              node[c[j-1]].right_sibling = c[j];
            }
          node[c[j]].parent = id;
          node[c[j]].id = c[j];
          // node[node[c[j]].id].depth = node[id].depth + 1;
        }
    }
  
  for(i=0; i<n; i++)
    {
      j = node[i].parent;
      
      while(1)
        {
          if(j == -1)
            {
              break;
            }
          
          j = node[j].parent;
          node[i].depth++;
        }
    }
  
 
  for(i=0; i<n; i++)
    {
      printf("node %d: parent = %d, depth = %d, ", node[i].id, node[i].parent, node[i].depth);
      
      if(node[i].parent == -1)
        {
          if(node[i].child != -1)
            {
              printf("root, [%d", node[i].child);
              j = node[i].child;
              while(node[j].right_sibling != -1)
                {
                  printf(", %d", node[j].right_sibling);
                  j = node[j].right_sibling;
                }
              printf("]\n");
            }
          else
            {
              printf("root, []\n");
            }
        }
      else if(node[i].parent != -1)
        {
          if(node[i].child != -1)
            {
              printf("internal node, [%d", node[i].child);
              j = node[i].child;
              while(node[j].right_sibling != -1)
                {
                  printf(", %d", node[j].right_sibling);
                  j = node[j].right_sibling;
                }
              printf("]\n");
            }
          else
            {
              printf("leaf, []\n");
            }
        }
      
    }

  return 0;
}