#include<stdio.h>
#define NIL -1
int getDepth(int);

typedef struct {
    int parent;
    int left;
    int right;
    int depth;

}Node;

Node T[10000];

int main(){
    int n,i,j,num,id,k,c[10000];

    scanf("%d",&n);

    for(i=0;i<n;i++){
        T[i].parent=NIL;
        T[i].left=NIL;
        T[i].right=NIL;
    }

    for(i=0;i<n;i++){
        scanf("%d",&id);
        scanf("%d",&k);
        for(j=0;j<k;j++){
             scanf("%d",&c[j]);
             if(j==0){
                 T[c[0]].parent=id;
                 T[id].left=c[0];
             }
             else {
                 T[c[j]].parent=id;
                 T[c[j-1]].right=c[j];
             }
        }
    }

    for(i=0;i<n;i++){
        printf("node %d: ",i);
        printf("parent = %d, ",T[i].parent);
        printf("depth =  %d, ",getDepth(i));
        if(T[i].parent==NIL && T[i].left==NIL){
            printf(" root, []");
        }
        else if(T[i].parent==NIL){
            printf(" root, [%d",T[i].left);
            for (j = T[T[i].left].right; j != NIL; j = T[j].right)
            {
                printf(", %d", j);
            }
            printf("]\n");
        }
        else if (T[i].left != NIL)
        {
            printf(" internal node, [%d", T[i].left);
            for (j = T[T[i].left].right; j != NIL; j = T[j].right)
            {
                printf(", %d", j);
            }
            printf("]\n");
        }

        else
        {
            printf(" leaf, []\n");
        }
    }
    return 0;
}

int getDepth(int i){
    int d=0;
    while(T[i].parent!=NIL){
        i=T[i].parent;
        d++;
    }
    return d;
}
