#include <stdio.h>
#define MAX_N 100000
#define NIL -1

typedef struct node_ {
    int parent;
    int left;
    int right;
} Node;

Node T[MAX_N];

int getDepth(int u) {
    int d = 0;
    while (u != NIL) {
        u = T[u].parent;
        d++;
    }
    return d;
}

void print(int u) {
    int i;
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("depth = %d, ", getDepth(u));

    if (T[u].parent == NIL) {
        printf("root, ");
    } else if (T[u].left == NIL) {
        printf("leaf, ");
    } else {
        printf("internal node, ");
    }

    int c = T[u].left;
    printf("[");
    for (i = 0; c != NIL; i++) {
        if (i) printf(", ");
        printf("%d", c);
        c = T[c].right;
    }
    printf("]\n");
}

int main(void) {
    int i, j, n;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }

    for (i = 0; i < n; i++) {
        int id, k, left;
        scanf("%d %d", &id, &k);
        for (j = 0; j < k; j++) {
            int c;
            scanf("%d", &c);
            if (j == 0) T[id].left = c;
            else T[left].right = c;
            left = c;
            T[c].parent = id;
        }
    }

    for (i = 0; i < n; i++) {
        print(i);
    }

    return 0;
}