#include <stdio.h>
#define MAX_NODE 100000

typedef int Item;

typedef struct node{
    Item item;
    int depth;
    struct node *parent;
    struct node *child;
    struct node *next;
} Node;

typedef struct tree{
    Node *root;
} Tree;

int getId(Node *node){
    return node->item;
}

int getParent(Node *node){
    if(node->parent != NULL) return node->parent->item;
    else return -1;
}

Node* getRoot(Node *node){
    if(node->parent == NULL) return node;
    else return getRoot(node->parent);
}

void setDepth(Node *root){
    if(root->parent == NULL) root->depth = 0;
    else root->depth = root->parent->depth + 1;

    if(root->child != NULL){
        Node *next = root->child;
        while(next != NULL){
            setDepth(next);
            next = next->next;
        }
    }
}

int getDepth(Node *node){
    return node->depth;
}

void printNode(Node *node){
    printf("node %d: ", node->item);
    printf("parent = %d, ", getParent(node));
    printf("depth = %d, ", getDepth(node));
    if(node->child == NULL) {
        if(node->parent == NULL) printf("root, ");
        else printf("leaf, ");
        printf("[]");
    }
    else {
        if (node->parent == NULL) printf("root, ");
        else printf("internal node, ");
        
        printf("[");
        Node *child = node->child;
        while(child != NULL){
            if(child->next == NULL) printf("%d]", child->item);
            else printf("%d, ", child->item);
            child = child->next;
        }

    }
    printf("\n");
}

int main(void){
    int n;
    scanf("%d\n", &n);
    
    Node node[MAX_NODE];
    
    int i;
    for(i = 0; i < n; i++){
        int id, k, j;
        scanf("%d%*c%d%*c", &id, &k);           
        node[id].item = id;
        for(j = 0; j < k; j++){
            int child;
            scanf("%d%*c", &child);
            
            node[child].parent =  &node[id];
            
            if(node[id].child == NULL) node[id].child = &node[child];
            else {
                Node *tail = node[id].child;
                while(tail->next != NULL) tail = tail->next;
                tail->next = &node[child];
            }
        }
    }
    
    Node *root = getRoot(&node[0]);
    setDepth(root);
    for(i = 0; i < n; i++){
        printNode(&node[i]);
    }


    return 0;
}