#include <stdio.h>
#include <stdlib.h>
#define NIL -1
#define MAX 100000
typedef struct node {
    int parent, left, right ;
}Node;
Node T[MAX];
int D[MAX];

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

void setDepth(int u, int p){
    //u is node id, p is depth
    D[u] = p;
    if (T[u].right != NIL)
        setDepth(T[u].right, p);
    if (T[u].left != NIL)
        setDepth(T[u].left, p+1);
}

void printChildren(int u){
    int c = T[u].left;
    while (c != NIL){
        if (c == T[u].left) printf("%d", c);
        else printf(" %d", c);
        c = T[c].right;
    }
}

int main(){
    int n, id, k;
    scanf("%d", &n);
    T[0].parent = NIL;
    T[0].right = NIL;
    for (int i = 0; i < n; i++){
        int children[MAX] = {-1, -1, -1, -1};
        scanf("%d %d", &id, &k);
        for (int j = 0 ; j < k; j++){
            scanf("%d", &children[j]);
            T[ children[j] ].parent = i;
        }
        for (int j = 0 ; j < k; j++){
            T[ children[j] ].right = children[j+1];
        }
        
        T[i].left = children[0];
    }
    setDepth(0, 0);

    for (int i = 0; i < n; i++){
        printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, D[i]);
        if (T[i].parent == NIL)
            printf("root, ");
        if (T[i].left != NIL)
            printf("internal node, ");
        if (T[i].left == NIL)
            printf("leaf, ");
        printf("[");
        printChildren(i);
        printf("]\n");
    }

    return 0;
}
