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

typedef struct node {
    int p;
    int l;
    int r;
} Node;

Node node[MAX];
int n, D[MAX];

int getDepth(int u){
    int d = 0;
    while(node[u].p != NIL){
        d++;
        u = node[u].p;
    }

    return d;
}

void setDepth(int u, int p){
    D[u] = p;
    if(node[u].l != NIL){
        setDepth(node[u].l, p + 1);
    } else if (node[u].r != NIL){
        setDepth(node[u].r, p);
    }
}

void print(int u){
    int c;
    printf("node ");
    printf("%d: ", u);

    printf("parent = %d, ", node[u].p);
    printf("depth = %d, ",  D[u]);
    if(node[u].p == NIL) printf("root, ");
    else if (node[u].l == NIL ) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(int i = 0, c = node[u].l; c != NIL; i++, c = node[c].r){
        if(i) printf(", ");
        printf("%d", c);
    }
    printf("]");

    printf("\n");


}

int main(){
    int id, k, i, j, v, l = 0;
    int tmp;

    scanf("%d", &n);
    /* initialize */
    for(i = 0; i < n; i++){
        node[i].p = node[i].l = node[i].r = NIL;
    }

    scanf("%d", &k);
    for(i = 0; i < n; i++){
        scanf("%d %d", &id, &k);
        
        for(j = 0; j < k; j++){
            tmp = scanf("%d", &v);
            if(j == 0) node[id].l = tmp;
            else node[l].r = tmp;
            l = tmp;
            node[tmp].p = id;
        }
    }

    printf("hre");
    setDepth(0, 0);
    for(i = 0; i < n; i++) print(i);
    return 0;
}
