#include <stdio.h>

struct tree{
    int parent;
    int children[20];
    int child;
    int depth;
};

struct tree ki[100000];

void setDepth(int, int);

int main(){
    int key, i, j, n, root;
    scanf("%d",&n);
 
    // init
    for(i = 0 ; i < n ; i++) {
        scanf("%d", &key);
        scanf("%d", &ki[key].child);
        for(j = 0 ; j < ki[key].child; j++) {
            scanf("%d", &ki[key].children[j]);
        }
        ki[key].parent = -1;
    }

    // set parent
    for (i = 0; i < n; i++) {
        for (j = 0; j < ki[i].child; j++) {
            ki[ki[i].children[j]].parent = i;
        }
    }

    // find root
    for (i = 0; i < n; i++) {
        if (ki[i].parent == -1) {
            root = i;
            break;
        }
    }

    setDepth(root, 0);

    // print
    for (i = 0; i < n; i++) {
        printf("node %d: parent = %d, depth = %d, ", i, ki[i].parent, ki[i].depth);
        if (ki[i].child > 0 || ki[i].depth == 0) {
            if (ki[i].depth == 0) printf("root, [");
            else printf("internal node, [");
            for (j = 0; j < ki[i].child; j++) {
                printf("%d",ki[i].children[j]);
                if(j != ki[i].child-1) printf(", ");
            }
            printf("]\n");
        }
        else printf("leaf, []\n");
    }

    return 0;
}

void setDepth(int id, int n) {
    int i;
    ki[id].depth = n;
    for (i = 0; i < ki[id].child; i++) {
        setDepth(ki[id].children[i], n+1);
    }
}
