#include<stdio.h>
#include <stdlib.h>
#define max 1000005
#define NIL -1

typedef struct
{
    int parent,left,right;
}Node;



Node node[max];
int depth[max];

int getDepth(int i)
{
   if(node[i].parent == NIL)
   {
       return 0;
   }
   return getDepth(node[i].parent)+1;
    }


void printing(int i, int n, int temp)
{
    for (i = 0; i != n; i++) {
  printf("node %d: parent = %d, depth = %d, ", i, node[i].parent, depth[i]);
  if (node[i].parent == NIL) {
   printf("root, ");
  }
  else if (node[i].left == NIL) {
   printf("leaf, ");
  }
  else
   printf("internal node, ");
printf("[");
  if (node[i].left != NIL) {
   printf("%d", node[i].left);
   temp = node[i].left;
   for(;;) {
    if (node[temp].right == NIL) {
     break;
    }
    printf(", %d", node[temp].right);
    temp = node[temp].right;
   }
  }
  printf("]\n");
 }
}



int main()
{
    int n;
    int i,j,k;
    int ID;
    int temp,m;
    int u;

    //size
    scanf("%d", &n);
    
    //set NIL
    for(i=0;i<n;i++){
        node[i].parent=node[i].left=node[i].right=NIL;
    }
    //scan
    for (i = 0; i != n; i++) {
  scanf("%d %d", &ID, &k);
  for (j = 0; j != k; j++) {
   scanf("%d", &m);
   if (j == 0) {
    node[ID].left = m;
    node[m].parent = ID;
    temp = m;
   }
   else {
    node[temp].right = m;
    node[m].parent = ID;
    temp = m;
   }
  }
 }

 for(i=0;i<n;i++)
 {
     depth[i]=getDepth(i);
 }

printing(i,n,temp);

 return 0;

} 

