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