#include <stdio.h>

typedef struct{
    int id;
    int parent;
    int left;
    int right;
    int depth;
}Tree;

Tree T[100000];

void print(int);

int main(){
    int i,j;
    int n;
    int id,pa,le,ri,depth;
    int data;
    scanf("%d",&n);
        //printf("n=%d\n",n);
    for(i=0;i<n;i++){
        T[i].id=-1;
        T[i].parent=-1;
        T[i].left=-1;
        T[i].right=-1;
        T[i].depth=0;
    }
    
    
    for(i=0;i<n;i++){
            //printf("i=%d{\n",i);
        scanf("%d",&id);
        T[id].id=id;
        
        scanf("%d",&j);
        if(j==0)continue;
        scanf("%d",&data);
        T[data].parent=id;
        T[id].left=data;
        j--;
        
        for(le=data;j>=1;j--){
                //printf("    j=%d\n",j);
            scanf("%d",&data);
            T[data].parent=id;
            T[le].right=data;
            le=data;
        }
            //printf("}\n");
    }
    
    for(i=0;i<n;i++){
        j=i;
        depth=0;
        while(T[j].parent!=-1){
            j=T[j].parent;
            depth++;
        }
        T[i].depth=depth;
    }
    
    for(i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,T[i].depth);
        if(T[i].parent==-1)printf("root, [");
        else if(T[i].left==-1)printf("leaf, [");
        else printf("internal node, [");
        if(T[i].left!=-1){
            ri=T[i].left;
            printf("%d",ri);
            while(T[ri].right!=-1){
                printf(", %d",T[ri].right);
                ri=T[ri].right;
            }
        }
        printf("]\n");
    }
    
    return 0;
}