#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* List, int ID)
{
    int counter=0;
    while(List[ID].parent!=NIL)
    {
        counter++;
        ID = List[ID].parent;
    }
    return counter;
}
int main() {
    int n, degree, temp, childlist, nodeID, nextsibling=0;
    scanf("%d", &n);
    Node* TreeList =(Node*)malloc(n*sizeof(Node));
    for(int i=0;i<n;i++)
    { TreeList[i].parent=NIL;TreeList[i].firstchild=RECO;TreeList[i].rightsibling=RECO;}
    for(int i=0;i<n;i++)
    {
        scanf("%d %d", &nodeID, &degree);
        for(int j=0;j<degree;j++)
        {
            scanf("%d", &childlist);
            TreeList[childlist].parent = nodeID;
            if(j==0){TreeList[nodeID].firstchild=childlist;}
            else
            {
                TreeList[nextsibling].rightsibling=childlist;
            }
            nextsibling = childlist;
        }
    }
    for(int i=0;i<n;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);
            temp = TreeList[i].firstchild;
            while(TreeList[temp].rightsibling!=RECO)
            {
                printf(", %d", TreeList[temp].rightsibling);
                temp = TreeList[temp].rightsibling;
            }
        }
        printf("]\n");
        
    }
    free(TreeList);
    return 0;
}


