#include <stdio.h>
#include <stdlib.h>

enum{
    ROOT,
    InternalNode,
    LEAF
};
typedef struct _node{
    int parent;
    int depth;
    int type;   //0:root,1:internal node,2:leaf
    int *child;
    int cCnt;
}NODE;

int getroot(NODE node[],int n){
    int i;
    for(i=0;i<n;i++)if(node[i].parent==-1)return i;
    
    return -1;
}
void getDepth(NODE node[],int id){
    if(node[id].depth==-1)node[id].depth=node[node[id].parent].depth+1;
    if(node[id].parent==-1)node[id].type=ROOT;
    else if(node[id].cCnt==0)node[id].type=LEAF;
    else node[id].type=InternalNode;
    
    int i;
    for(i=0;i<node[id].cCnt;i++)getDepth(node,node[id].child[i]);
    return;
}

void printNode(NODE node[],int n){
    int i,j;
    for(i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d, ",i,node[i].parent,node[i].depth);
        switch(node[i].type){
            case ROOT:
                printf("root");
                break;
            case InternalNode:
                printf("internal node");
                break;
            case LEAF:
                printf("leaf");
                break;
        }
        printf(", [");
        for(j=0;j<node[i].cCnt;j++){
            if(j==0)printf("%d",node[i].child[j]);
            else printf(", %d",node[i].child[j]);
        }
        printf("]\n");
    }
    return;
}
int main(void){
    int i,j;
    
    int n;
    scanf("%d\n",&n);
    
    NODE node[n];
    for(i=0;i<n;i++){
        node[i].parent=-1;
        node[i].depth=-1;
        node[i].type=-1;
        node[i].child=NULL;
        node[i].cCnt=0;
    }
    
    int id,k,c;
    for(i=0;i<n;i++){
        scanf("%d %d ",&id,&k);
        if(k>0)node[id].child=(int*)malloc(sizeof(int)*k);
        node[id].cCnt=k;
        for(j=0;j<k;j++){
            scanf("%d",&c);
            node[id].child[j]=c;
            node[c].parent=id;
        }
    }
    
    int root;
    root=getroot(node,n);
    if(root==-1)return -1;
    
    node[root].depth=0;
    node[root].type=ROOT;
    getDepth(node,root);
    
    printNode(node,n);
    
    for(i=0;i<n;i++){
        if(node[i].child!=NULL)free(node[i].child);
    }
    
    return 0;
}

