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

typedef struct{
    int parent;
    int l;
    int r;
    int d;
}Node;

Node Tree[100001];

int dep;
int getDep(int ppp){
    if(Tree[ppp].parent == -1) return 0;
    dep = getDep(Tree[ppp].parent) + 1;
    return dep;
}

void scan(int n){
    int id, number;
    int p1, p2;
    for(int i=0; i<n; i++){
        scanf("%d %d", &id, &number);
        for(int j=0; j<number; j++){
            scanf("%d", &p1);
            if(j==0){
                Tree[id].l = p1;
                Tree[p1].parent = id;
                p2 = p1;
            }
            else{
                Tree[p2].r = p1;
                Tree[p1].parent = id;
                p2 = p1;
            }
        }
    }
}

void depppp(int n){
    for(int i =0; i<n; i++){
        Tree[i].d = getDep(i);
    }
}
int main(){
    int n;
    scanf("%d", &n);

    for(int i=0;i<n;i++){
        Tree[i].parent = Tree[i].l = Tree[i].r=-1;
    }
    scan(n);

    depppp(n);

    int ppp;
    for(int i=0; i<n; i++){
        printf("node %d: parent = %d, depth = %d, ", i, Tree[i].parent, Tree[i].d);
        if(Tree[i].parent == -1){
            printf("root, []\n");
        }
        else if(Tree[i].l == -1){
            printf("leaf, []\n");
        }
        else{
            printf("internal node, [");
            if(Tree[i].l != -1){
                printf("%d", Tree[i].l);
                ppp = Tree[i].l;
                for(int k=0; k<n; k++){
                    if(Tree[ppp].r == -1) break;
                    printf(", %d", Tree[ppp].r);
                    ppp = Tree[ppp].r;
                }
            }
            printf("]\n");
        }

    }
    return 0;
}
