#include<stdio.h>

#define N 100000
#define NIL -1

void degree(int);
int depth(int);

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

Node T[N];
int x = 0;

int main(){
    int i, j, n, c, k, newcode, left, right;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;
    
    for(i = 0; i < n; i++){
        scanf(" %d%d", &newcode, &k);
        for(j = 0; j < k; j++){
            scanf("%d", &c);
            T[c].p = newcode;
            if(j == 0) T[newcode].l = c;
            else T[left].r = c;
            left = c;
        }
    }
    
    for(i = 0; i < n; i++){
        x = 0;
        printf("node %d: parent = %d, depth = %d, ", i, T[i].p, depth(i));
        if(T[i].p == NIL) printf("root, [");
        else if(T[i].l == NIL) printf("leaf, [");
        else printf("internal node, [");
        x = 0;
        degree(T[i].l);
        printf("]\n");
    }
    
    return 0;
    
}

void degree(int nodeid){
    if(nodeid != NIL){
        if(x != 0){
            printf(", ");
        }
        printf("%d", nodeid);
        x++;
        degree(T[nodeid].r);
    }
}

int depth(int nodeid){
    if(T[nodeid].p == NIL) return x;
    else {
        x++;
        return depth(T[nodeid].p);
    }
}