#include <stdio.h>
#include <stdlib.h>
#define FAMILY -1
#define MAX 100000
int par[MAX], deg[MAX], *chil[MAX],i,j,n, id, k;
int dep(int);
void input(void);
void output(void);
int main(void){
    // node number
    scanf("%d", &n);
    // initialize
    for(i=0; i<n; i++)  par[i] = FAMILY;
    input();
    output();
    
}
void input(void){
    for(j=0; j<n; j++){
        scanf("%d%d", &id, &k);
        deg[id] = k;
        chil[id] = (int*)malloc(sizeof(int)*k);
        i=0;
        while(i<k){
            scanf("%d", &chil[id][i]);
            par[chil[id][i]] = id;
            i++;
        }
    }
}

void output(void){
    for(i=0; i<n; i++){
        printf("node %d: parent = %d, depth = %d, ", i, par[i], dep(i));
        if(par[i] == FAMILY) printf("root, [");
        else if(deg[i] == 0) printf("leaf, [");
        else    printf("internal node, [");
        j=0;
        while(j<deg[i]){
            printf("%d", chil[i][j]);
            if(j < deg[i] - 1)   printf(", ");
            j++;
        }
        printf("]\n");
    }
}
int dep(int num){
    return (par[num] == FAMILY) ? 0 : (dep(par[num]) + 1);
}
