typedef struct
{
    int id;
    int degree;
    int *children;
    int parent;
    int depth;
    int quilty;
}Node;
#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */
void findParent(Node *node, int size);
int findDepth(Node a, Node *node);
void quilty(Node *a, int size);
int main(int argc, char** argv) {
    int size;
    scanf("%d",&size);
    Node node[size];
    for(int i = 0; i<size;i++)
    {
        scanf("%d",&node[i].id);
        scanf("%d",&node[i].degree);
        node[i].children = (int*)malloc(sizeof(int)*node[i].degree);
        if(node[i].degree != 0)
        {
            for(int j=0; j < node[i].degree; j++)
            {
                int readScan = scanf("%d",&node[i].children[j]);
            } 
        }
    }
    
    findParent(node, size);
    
    for(int i=0; i<size;i++)
    {
        node[i].depth = findDepth(node[i], node);
    }
    
    quilty(node, size);
    
    for(int i= 0; i<size;i++)
    {
        printf("node %d: ", node[i].id);
        printf("parent = %d, ", node[i].parent);
        printf("depth = %d, ", node[i].depth);
        if(node[i].quilty==1)
        {
            printf("root, ");
        }
        if(node[i].quilty==2)
        {
            printf("internal node, ");
        }
        if(node[i].quilty==3)
        {
            printf("leaf, ");
        }

        printf("[");
        for(int j=0; j < node[i].degree; j++)
        {
            if(j<node[i].degree-1)
            {
                printf("%d, ",node[i].children[j]);
            }
            if(j==node[i].degree-1)
            {
                printf("%d",node[node[i].children[j]]);
            }
        }
        printf("]\n");
    }
  

    return (EXIT_SUCCESS);
}

void findParent(Node *node, int size)
{
  
    for(int i=0;i<size; i++)
    {
        for(int j=0;j<size;j++)
        {
            if(node[j].degree>0)
            {
                for(int k=0;k<node[j].degree;k++)
                {
                   if(node[i].id == node[j].children[k])
                   {
                      node[i].parent = node[j].id;
                   }
                }
                if(node[i].parent == NULL)
                    node[i].parent = -1;
            }
        }
    }
}

int findDepth(Node a, Node *node)
{
    int count = 0;
    if(a.parent != -1)
    {
        count = count + findDepth(node[a.parent], node);
        count++;
    }
    return count;
}

void quilty(Node *a, int size)
{
    for(int i=0;i<size;i++)
    {
        if( a[i].parent==-1)
        {
            a[i].quilty=1;
        }
        if(a[i].degree!=0 && a[i].parent !=-1)
        {
            a[i].quilty=2;
        }
        if(a[i].degree==0 && a[i].parent!=-1)
        {
            a[i].quilty=3;
        }
  
    }
}
