#include<cstdio>
 
struct node{
    int parent;
    int left;
    int right;
    int sibling;
    int degree;
    int depth;
    int height;
};
 
node tree[25];
 
 
int takasa(int id){
    if(id == -1)
        return -1;
    if(tree[id].left == -1 && tree[id].right == -1){
        tree[id].height = 0;
        return 1;
    }
    int a = takasa(tree[id].left);
    int b = takasa(tree[id].right);
    tree[id].height =  a >= b ? a : b;
    return tree[id].height + 1;
}
void hukasa(int depth,int id){
    tree[id].depth = depth;
    if(tree[id].left >= 0)
        hukasa(depth + 1,tree[id].left);
    if(tree[id].right >= 0)
        hukasa(depth + 1,tree[id].right);
}
 
 
int main(void){
    int n;
    scanf("%d",&n);
 
    for(int i = 0;i < n;i++){
        tree[i].sibling = -1;
        tree[i].degree = 0;
        tree[i].parent = -1;
    }
    for(int i = 0;i < n;i++){
        int id,left,right;
        scanf("%d%d%d",&id,&left,&right);
        tree[id].left = left;
        tree[id].right = right;
        if(left >= 0){
            tree[left].parent = id;
            tree[id].degree++;
        }
        if(right >= 0){
            tree[right].parent = id;
            tree[id].degree++;
        }
        if(left >= 0 && right >= 0){
            tree[left].sibling = right;tree[right].sibling = left;
        }
    }
    int root;
    for(int i = 0;i < n;i++)
        if(tree[i].parent == -1){
            root =  i;
            break;
        }
    hukasa(0,root);
    takasa(root);
 
    for(int i = 0;i < n;i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,tree[i].sibling,tree[i].degree,tree[i].depth,tree[i].height);
 
        if(tree[i].parent == -1){
            printf("root");
	}
        else if(tree[i].left >= 0 || tree[i].right >= 0){
            printf("internal node");
	}
        else
            printf("leaf");
        printf("\n");
    }
    return 0;
}