#include<stdio.h>
#define MAX 100000
#define NIL -1
struct tree {
        int parent;
        int left;
        int right;
};
void depth(int, int, struct tree*, int*);
void disp(int, struct tree*, int*);
main()
{
        struct tree t[MAX];
        int i, j, n, id, k, c, prec, root, d[MAX];
        scanf("%d", &n);
        for (i = 0; i < n; i++) {
                t[i].parent = t[i].left = t[i].right = NIL;
        }
    for(i = 0; i < n; i++) {
        scanf("%d %d", &id, &k);
        for(j = 0; j < k; j++) {
            scanf(" %d", &c);
            if (!j) {
                                t[id].left = c;
                        } else {
                                t[prec].right = c;
                        }
            prec = c;
            t[c].parent = id;
        }
    }
    for (i = 0; i < n; i++) {
        if(t[i].parent == NIL) {
                        root = i;
                        break;
                }
        }
        depth(root, 0, t, d);
        for (i = 0; i < n ; i++) {
                disp(i, t, d);
        }
}
void depth(int u, int p, struct tree *t, int *d)
{
        d[u] = p;
        if (t[u].right != NIL) {
                depth(t[u].right, p, t, d);
        }
        if (t[u].left != NIL) {
        depth(t[u].left, p + 1, t, d);
    }
}
void disp(int u, struct tree *t, int *d)
{
        int c;
        printf("node %d: parent = %d, depth = %d, ", u, t[u].parent, d[u]);
        if (t[u].parent == NIL) {
                printf("root, [");
                if (t[u].left == -1) {
                        printf("]\n");
                        return;
                }
        } else if (t[u].left != NIL) {
                printf("internal node, [");
        } else {
                printf("leaf, []\n");
                return;
        }
        for (c = t[u].left; t[c].right != NIL; c = t[c].right) {
                printf("%d, ", c);
        }
        printf("%d]\n", c);
}