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

//#define n_size 100000

typedef struct node_
{
    int kosu;
    int *hyo;
    int parent;
//    int depth;
} Node;

int main()
{
    int n,node,ko,dep,tmp=0;
    Node *N;
    scanf("%d",&n);
    N = malloc(sizeof(Node)*n);
    for(int i=0;i<n;i++) N[i].parent = -1; 
    for(int i=0;i<n;i++)
    {
        scanf("%d %d",&node,&ko);
        N[node].kosu = ko;
        if(ko != 0)  N[node].hyo = malloc(sizeof(int)*ko);
        //parent探し
        for(int j=0;j<ko;j++)
        {
            scanf("%d",&tmp);
            N[node].hyo[j] = tmp;
            N[tmp].parent = node;
            //fprintf(stderr,"%dのhyo=%d,",i,N[node].hyo[j]);
        }
        //fprintf(stderr,"\n");
    }
    //階層探し
    for(int i=0;i<n;i++)
    {
        dep = 0;
        for(int j=i;N[j].parent != -1;j=N[j].parent)
        {
            dep +=1;
        }
//        N[i].depth = dep;
        printf("node %d: parent = %d, depth = %d, ",i,N[i].parent,dep);
        if(dep == 0){
            printf("root, ");
        }else if(N[i].kosu != 0){
            printf("internal node, ");
        }else {
            printf("leaf ");
        }
        
        //fprintf(stderr,"N[%d].hyo=%p\n", i, N[i].hyo);
        printf("[");
        for(int j=0;j<N[i].kosu;j++){
            if(j == 0)     printf("%d",N[i].hyo[j]);
            else printf(", %d",N[i].hyo[j]);
        }
        printf("]\n");
        //free(N[i].hyo);
    }
    //free(N);
}
