#include <stdio.h>

#define MAX (100000 + 2)
#define NIL (-1)

struct node {
        int parent;
        int left_child;
        int right_brother;
};

struct node T[MAX];
int D[MAX];

int
get_depth(int id)
{
        int depth = 0;

        while (T[id].parent != NIL) {
                id = T[id].parent;
                depth++;
        }

        return depth;
}

void
print_children(int id)
{
        int child;
        int i;

        child = T[id].left_child;

        for (i = 0; child != NIL; i++) {
                if (i)
                        printf(", %d", child);
                else
                        printf("%d", T[id].left_child);
                child = T[child].right_brother;
        }
}

int
main(void)
{
        int node_num;
        int dimention = MAX - 1;
        int id;
        int id_left;
        int i, j;
        int read_array[MAX];

        scanf("%d", &node_num);

        for (i = 0; i < node_num; i++)
                T[i].parent = T[i].left_child = T[i].right_brother = NIL;

        for (i = 0; i < node_num; i++) {
                read_array[1] = MAX - 1;

                for (j = 0; j < dimention + 2; j++) {
                        scanf("%d", &read_array[j]);

                        if (j == 0)
                                id = read_array[0];
                        if (j == 1)
                                dimention = read_array[1];

                        if (j == 2)
                                T[id].left_child = read_array[j];
                        if (2 < j)
                                T[id_left].right_brother = read_array[j];
                        id_left = read_array[j];

                        if (1 < j)
                                T[read_array[j]].parent = id;
                }
                T[id_left].right_brother = NIL;
        }

        for (i = 0; i < node_num; i++)
                D[i] = get_depth(i);

        for (i = 0; i < node_num; i++) {
                printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, D[i]);

                if (T[i].parent == NIL)
                        printf("root, ");
                else if (T[i].left_child == NIL)
                        printf("leaf, ");
                else
                        printf("internal node, ");

                printf("[");
                print_children(i);
                printf("]\n");
        }

        return 0;
}
