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


struct Node {
    int id;
    int parent;
    int childs_num;
    int* childs;
    int depth;
};

static const char* GetType(const struct Node* p_node) {
    if ( p_node->parent == - 1 ) {
        return "root";
    }
    if ( p_node->childs_num == 0 ) {
       return "leaf";
    }

    return "internal node";
}

static int FindRoot(const struct Node nodes[], int n) {
    int i;

    for ( i = 0; i < n; i++ ) {
        if ( nodes[i].parent == -1 ) {
            return nodes[i].id;
        }
    }
    assert( 0 );

    return -1;
}

static void UpdateDepth(int root, struct Node nodes[], int n) {
    int i;

    if ( nodes[root].childs_num == 0 ) {
        return;
    }

    for ( i = 0; i < nodes[root].childs_num; i++ ) {
        int c = nodes[root].childs[i];
        nodes[c].depth = nodes[root].depth + 1;
        UpdateDepth(c, nodes, n);
    }

    return;
}

int main() {
    int i, j;
    int n;
    struct Node* nodes;

    scanf("%d\n", &n);

    nodes = malloc(sizeof(struct Node) * n);

    for (i = 0; i < n; i++) {
        nodes[i].parent = -1;
        nodes[i].depth = 0;
    }
    for (i = 0; i < n; i++) {
        int id, k;

        scanf("%d %d", &id, &k);
        nodes[id].id = id;
        nodes[id].childs_num = k;
        nodes[id].childs = malloc(sizeof(int) * k);

        for (j = 0; j < k; j++) {
            int c;
            scanf("%d", &c);

            nodes[id].childs[j] = c;
            nodes[c].parent = id;
        }
          /* new line */
        (void)fgetc(stdin);
    }

    int root = FindRoot(nodes, n);

    UpdateDepth(root, nodes,n);

    for ( i = 0; i < n; i++ ) {
        printf("node %d: parent = %d, depth = %d, %s, ", nodes[i].id, nodes[i].parent, nodes[i].depth, GetType(&nodes[i]));

        printf("[");
        for ( j = 0; j < nodes[i].childs_num; j++ ) {
            printf("%d", nodes[i].childs[j]);
            if ( j + 1 < nodes[i].childs_num ) {
                printf(", ");
            }
        }
        printf("]\n");
    }

    for ( i = 0; i < n; i++ ) {
        if ( nodes[i].childs_num > 0 ) {
            free(nodes[i].childs);
        }
    }

    free(nodes);

    return 0;
}

