#include<stdio.h>
#define MAX 100000
int depth(int, int);
void print(int);
struct node{
    int p,l,r;
};
struct node data[MAX];
int n, data2[MAX];

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