

#include <stdio.h>
#include <stdlib.h>
typedef struct Node Node;
struct Node{
    int id;
    Node* parent;
    Node* rcbling;
    Node* lchild;
};

void initialize(Node* n);
int findDepth(Node* a);
int main(int argc, char** argv) {
    int size;
    scanf("%d", &size);
    Node array[size];
    
    int degree;
    int location, tempP, tempC = -1;
    for(int i=0;i<size;i++)
    {
        initialize(&array[i]);
    }
    
    for(int i=0;i<size;i++)
    { 
        scanf("%d %d", &tempP, &degree);
        array[tempP].id = tempP;
        for(int j=0;j<degree;j++)
        {
           
            scanf("%d",&location);
            array[location].parent=array + tempP;
            if(j==0)
            {
                array[tempP].lchild = array + location;
            }
            if(tempC>=0)
            {
                array[tempC].rcbling = array + location;
            }
            tempC = location;
        }
        tempC = -1;
    }
    
    int temp, temp2P, type;
    for(int i=0; i<size; i++)
    {
        printf("node %d: ", i);
        if(array[i].parent == NULL)
            temp2P = -1;
        else
            temp2P = array[i].parent->id;
        printf("parent = %d, ", temp2P);
        printf("depth = %d, ", findDepth(&array[i]));
        if(array[i].parent==NULL)
            type = 1;
        else{
            if(array[i].lchild!=NULL)
                type = 2;
            else
                type = 3;
        }
        if(type == 1)
        {
            printf("root, [");
        }
        if(type == 2)
        {
            printf("internal node, [");
        }
        if(type == 3)
        {
            printf("leaf, [");
        }
        if(array[i].lchild != NULL){
            temp = array[i].lchild->id;
            printf("%d", temp);
            while(array[temp].rcbling!=NULL){
                if(array[temp].rcbling != NULL)
                    printf(", ");
            temp = array[temp].rcbling->id;
            printf("%d", temp);
            }
        }
        printf("]\n");
        
    }
    
    return (EXIT_SUCCESS);
}


void initialize(Node* n)
{
    n->id = -1;
    n->lchild = NULL;
    n->rcbling = NULL;
    n->parent = NULL;
}

int findDepth(Node* a)
{
    int count = 0;
    if(a->parent !=NULL)
    {
        count++;
        count = count + findDepth(a->parent);  
    }
    return count;
}
