#include<stdio.h>
#define MAX 100000
#define NIL -1

typedef struct{
    int parent;
    int left;
    int right;
}Node;

Node T[MAX];
int n;
int Depth[MAX];
int child[MAX];

int getDepth(int i)
{
    int count=0;
    while(T[i].parent>=0){
        i=T[i].parent;
        count++;
    }
    return count;
}

void print(int i)
{
    int count=0,k;
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,Depth[i]);
    if(T[i].parent==NIL) printf("root, [");
    else if(T[i].left==NIL) printf("leaf, [");
    else printf("internal node, [");
    i=T[i].left;
    while(i!=NIL){
        if(count==0) printf("%d",i);
        else printf(", %d",i);
        i=T[i].right;
        count++;
    }
    printf("]\n");
}

int main(){
    int i,j;
    int vertex,degree;
    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%d",&vertex,&degree);
        for(j=0;j<degree;j++){
            scanf("%d",&child[j]);
            T[child[j]].parent=vertex;
            if(j==0) T[i].left=child[0];
            else T[child[j-1]].right=child[j];
        }
    }
    for(i=0;i<n;i++) Depth[i]=getDepth(i);
    for(i=0;i<n;i++) print(i);
    return 0;
}