//
// Created by kota_ on 2019/12/28.
//
#include <stdio.h>
#include <stdlib.h>

typedef struct node{
    int id;
    struct node *child;
    struct node *sibling;
    struct node *parent;
}Node;

typedef Node* Nodepointer;


Node make_1node(int id){
    Node ret;
    ret.id = id;
    ret.child = NULL;
    ret.sibling = NULL;
    ret.parent = NULL;
    return ret;
}

int get_parent_value(Nodepointer);
int get_depth(Nodepointer);


int main(){
    int i, j, n, id, k, depth;
    Nodepointer nodes, parent, child_left, child_right;
    scanf("%d", &n);
    nodes = malloc(sizeof(Node) * n);
    for(i = 0; i < n; i++){
        nodes[i] = make_1node(i);
    }
    for(i = 0; i < n; i++){
        scanf("%d %d", &id, &k);
        parent = &nodes[id];
        for(j = 0; j < k; j++){
            scanf("%d", &id);
            child_right = &nodes[id];
            child_right->parent = parent;
            if(j == 0){
                parent->child = child_right;
            }
            else{
                child_left->sibling = child_right;
            }
            child_left = child_right;
        }
    }
    for(i = 0; i < n; i++){
        parent = &nodes[i];
        printf("node %d: parent = %d, ", i, get_parent_value(parent));
        depth = get_depth(parent);
        printf("depth = %d, ", depth);
        if(depth == 0){
            printf("root, ");
        }
        else if(parent->child != NULL){
            printf("internal node, ");
        }
        else{
            printf("leaf, ");
        }
        printf("[");
        for(child_left = parent->child; child_left != NULL; child_left = child_left->sibling){
            printf("%d", child_left->id);
            if(child_left->sibling != NULL){
                printf(", ");
            }
        }
        printf("]\n");

    }
    free(nodes);
    return 0;
}

int get_parent_value(Nodepointer target) {
    if (target->parent == NULL) {
        return -1;
    } else {
        return target->parent->id;
    }
}

int get_depth(Nodepointer target){
    int depth = 0;
    while(target->parent != NULL){
        depth++;
        target = target->parent;
    }
    return depth;
}


