#include<stdio.h>
#include<stdlib.h>   
typedef struct node{
    int p;
    int left;
    int right;
} Node;  
int searchHight(int);
Node *node;
int main(){
       
    int n,i,id,depth,tmpP,d,nowNode,s;
   
    scanf("%d",&n);
   
    node = malloc(sizeof(Node)*n);
   
    for (i = 0; i < n; ++i){
        node[i].p = -1;
    }
   
    for (i = 0; i < n; ++i){
        scanf("%d",&id);
        scanf("%d%d",&node[id].left,&node[id].right);
        node[node[id].left].p = id;
        node[node[id].right].p = id;
    } 
    nowNode = 0;
    while(1){
        if (node[nowNode].left != -1 && node[nowNode].right != -1)
        {
            break;
        } else if (node[nowNode].left == -1)
        {
            nowNode = node[nowNode].right;
        } else {
            nowNode = node[nowNode].left;
        }
    }
   
    for (i = 0; i < n; ++i){
           
        tmpP = node[i].p;
        if (tmpP == -1) s = -1;
        else if(node[tmpP].left == i) s = node[tmpP].right;
        else s = node[tmpP].left;
 
        depth = 0;
        while(tmpP != -1){
            tmpP = node[tmpP].p;
            depth++;
        }
   
 
        d = 0;
        if (node[i].left != -1) d++;
        if (node[i].right != -1) d++;
   
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",i,node[i].p,s,d,depth,searchHight(i));
   
        if(node[i].p == -1) printf("root\n");
        else if(node[i].left == -1 && node[i].right == -1) printf("leaf\n");
        else printf("internal node\n");
    }
   
    return 0;
}
   
int searchHight(int index){
    int hLeft = 0;
    int hRight = 0;
   
    if (node[index].left != -1){
        hLeft = searchHight(node[index].left) +1;
    }
    if (node[index].right != -1){
        hRight = searchHight(node[index].right) +1;
    }
    if (hLeft < hRight) return hRight;
    else return hLeft;
}