#include <stdio.h>
#include <stdlib.h>
#define MAX 100000

typedef struct{
    int id;
    int parent;
    int left;
    int right;//Rooted??§????????????????????????
    int depth;
}Tree;

int main(){
    char pr;
    int n,i,j,count,d;
    int data;
    char *c;
    c=&pr;
    scanf("%d",&n);
    Tree a[n];
    
    for(i=0;i<n;i++){
        a[i].id=-1;
        a[i].parent=-1;
        a[i].left=-1;
        a[i].right=-1;
        a[i].depth=0;
    }
    
    for(i=0;i<n;i++){
        //printf("i=%d{\n",i);
        scanf("%d",&data);
        a[i].id=data;
        scanf("%d",&data);
        a[i].left=data;
        //printf(" data=%d\n",data);
        if(data==0)continue;
        count=data;
        for(j=0;j<count;j++){
            //printf("  j=%d\n",j);
            scanf("%d",&data);
            a[data].parent=a[i].id;
            a[a[i].left].right=data;
        }
        //printf("}\n");
    }

    for(i=0;i<n;i++){
        d=0;
        j=i;
        while(a[j].parent!=-1){
            j=a[j].parent;
            d++;
        }
        a[i].depth=d;
    }
    
    for(i=0;i<n;i++){
        printf("node %d: parent = %d, depth = %d, ",a[i].id,a[i].parent,a[i].depth);
        if(a[i].parent==-1)printf("root, [");
        else if(a[i].left==0)printf("leaf, [");
        else printf("internal node, [");
        count=0;
        for(j=0;j<n;j++){
            if(count==0&&a[j].parent==a[i].id){
                printf("%d",a[j].id);
                count++;
            }
            else if(a[j].parent==a[i].id)printf(", %d",a[j].id);
        }
        printf("]\n");
    }
    
    return 0;
    
}