#include<stdio.h>
#define M 100001

typedef struct{
    int p,l,r;
}Node;

Node N[M];

int depth(int i,int d){
    if(N[i].p==-1)    return d;
    else return depth(N[i].p,++d);
}

int main(void){
    int i,j,n,m,id,c,l,r;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        N[i].p=-1;
        N[i].l=-1;
        N[i].r=-1;
    }
    
    for(i=0;i<n;i++){
        scanf("%d %d",&id,&m);
        for(j=0;j<m;j++){
            scanf("%d",&c);
            if(j==0) N[id].l=c;
            else     N[l].r=c;
            l=c;
            N[l].p=id;
        }
    }
    
    for(i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d, ",i,N[i].p,depth(i,0));
        if(N[i].p==-1) printf("root, ");
        else if(N[i].l==-1) printf("leaf, ");
        else printf("internal node, ");
        if(N[i].l==-1) printf("[]");
        else{
            printf("[%d",N[i].l);
            l=N[i].l;
            while(1){
                if(N[l].r==-1){
                    printf("]");
                    break;
                }
                else printf(",");
                printf(" %d",N[l].r);
                l=N[l].r;
            }
        }
        printf("\n");
    }
    return 0;
}
