#include <stdio.h>
#include <stdlib.h>
 
struct node{
    int id;
    struct node *parentNode;
    struct node *firstChild;
    struct node *nextSibling;
};
 
struct node* createNode(int);
struct node* searchNode(int);
 
struct node* nodes[100001];
int n;
 
int main(){
 
int i,j;
int id,k;
int tmpId;
int depth;
struct node* currentNode;
struct node* tmpNode;
struct node* prevNode;
 
scanf("%d",&n);
     
for(i=0;i<n;i++){
    scanf("%d",&id);
    currentNode = createNode(id);
    scanf("%d",&k);
    for(j=0;j<k;j++){
        scanf("%d",&tmpId);
        tmpNode = createNode(tmpId);
        tmpNode->parentNode = currentNode;
        if(j==0){ // firstChild
            currentNode->firstChild = tmpNode;
        }else{ // nextSibling
            prevNode->nextSibling = tmpNode;
        }
        prevNode=tmpNode;
    }
}
     
    for(i=0; i<n; i++){
         
        printf("node %d: ",nodes[i]->id);
        printf("parent = %d, ",(nodes[i]->parentNode?nodes[i]->parentNode->id:-1));
         
        depth = 0;
        tmpNode = nodes[i]->parentNode;
        while(tmpNode){
            depth++;
            tmpNode = tmpNode->parentNode;
        }
        printf("depth = %d, ",depth);
         
        if(nodes[i]->firstChild==NULL) printf("leaf");
        else if(depth==0) printf("root");
        else printf("internal node");
         
        printf(", [");
         
        tmpNode = nodes[i]->firstChild;
        while(tmpNode){
            printf("%d",tmpNode->id);
            tmpNode = tmpNode->nextSibling;
            if(tmpNode) printf(", ");
            else break;
        }
         
        printf("]\n");
    }
 
return 0;
}
 
struct node* createNode(int id){
    struct node *newNode = searchNode(id);
    //static int nodesLength = 0;
    if(newNode) return newNode;
    newNode = (struct node*)malloc(sizeof(struct node));
    newNode->id=id;
    newNode->parentNode = NULL;
    newNode->firstChild = NULL;
    newNode->nextSibling = NULL;
    //nodes[nodesLength++] = newNode;
    nodes[id] = newNode;
    return newNode;
}
 
struct node* searchNode(int id){
    if(nodes[id]) return nodes[id];
    return NULL;
    /*
    int i;
    for(i=0; i<n; i++){
         
        if(nodes[i]==NULL) break;
        if(nodes[i]->id==id){
            return nodes[i];
        }
    }
    return NULL;
    */
}