#include <stdio.h>

int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
void put_str(char *str) { while(*str) putchar_unlocked(*str++); }

typedef struct Node { int parent, left, right, depth; } Node;
void tree_depth(Node *tree, int node, int depth) {
    tree[node].depth = depth;
    for(int i = tree[node].left; ~i; i = tree[i].right) {
        tree_depth(tree, i, depth + 1);
    }
}
int main(int argc, char **argv) {
    int n = get_uint();
    Node tree[n];
    for(int i = 0; i < n; ++i) tree[i].parent = tree[i].left = tree[i].right = -1;
    for(int i = 0; i < n; ++i) {
        int id = get_uint();
        int k = get_uint();
        for(int j = 0, d; j < k; ++j) {
            int c = get_uint();
            tree[c].parent = id;
            if(j) tree[d].right = c;
            else tree[id].left = c;
            d = c;
        }
    }
    for(int i = 0; i < n; ++i) {
        if(tree[i].parent == -1) {
            tree_depth(tree, i, 0);
            break;
        }
    }
    for(int i = 0; i < n; ++i) {
        put_str("node ");
        put_uint(i);
        put_str(": parent = ");
        if(~tree[i].parent) put_uint(tree[i].parent);
        else put_str("-1");
        put_str(", depth = ");
        put_uint(tree[i].depth);
        put_str(~tree[i].parent ? ~tree[i].left ? ", internal node, [" : ", leaf, [" : ", root, [");
        if(~tree[i].left) {
            int j = tree[i].left;
            put_uint(j);
            for(j = tree[j].right; ~j; j = tree[j].right) {
                put_str(", ");
                put_uint(j);
            }
        }
        put_str("]\n");
    }
    return 0;
}

