#include <stdio.h>
#include <stdlib.h>
typedef struct P{
    int parent;
    int *child;
    int childlen;
}Node;

int depth(Node node[],int n){
    if(node[n].parent==-1){
        return 0;
    }
    return depth(node,node[n].parent)+1;
}

int main(void){
    int n,i,j,k,l,d;
    Node *node;
    scanf("%d",&n);
    node = (Node*)malloc(sizeof(Node)*n);
    for(i=0;i<n;i++){
        node[i].parent = -1;
    }
    for(i=0;i<n;i++){
        scanf("%d",&k);
        scanf("%d",&l);
        node[k].child = (int*)malloc(sizeof(int)*l);
        node[k].childlen = l;
        for(j=0;j<l;j++){
            scanf("%d",&node[k].child[j]);
            node[node[k].child[j]].parent = k;
        }
    }
    
    for(i=0;i<n;i++){
        printf("node %d: ",i);
        printf("parent = %d, ",node[i].parent);
        printf("depth = %d, ",depth(node,i));
        if(node[i].parent==-1){  printf("root, ");  }
        else if(node[i].childlen==0){  printf("leaf, ");  }
        else{  printf("internal node, ");  }
        printf("[");
        for(j=0;j<node[i].childlen;j++){
            printf("%d",node[i].child[j]);
            if(j!=node[i].childlen-1){
                printf(", ");
            }
        }
        printf("]\n");
    }
}
