#include<stdio.h>

#define MAX 25
#define NIL -1

int Height_get(int);
int Height[MAX];
typedef struct{
    int parent;
    int leaf_l;
    int leaf_r;
    int root;
}tree;

tree T[MAX];

int main(){

    int deg=0,maxd=0,n,i,j,id,left,right,Npare,cnt,height1,height2;

    scanf("%d",&n);
     for(i=0;i<n;i++){
        T[i].parent=NIL;
        T[i].leaf_l=T[i].leaf_r=NIL;
        T[i].root=NIL;

    }

    for(i=0;i<n;i++){
        scanf("%d %d %d",&id,&left,&right);
        T[id].leaf_l = left;
        T[id].leaf_r = right;
        if(left >= 0) T[left].parent = id;
        if(right >= 0) T[right].parent = id;
    }

//print section

    for(i=0;i<n;i++){

        printf("node %d: ",i);
        printf("parent = %d, ",T[i].parent);

        if(T[i].parent==NIL) printf("sibling = -1, ");
        else if(T[T[i].parent].leaf_l!=i && T[T[i].parent].leaf_l!=NIL)
            printf("sibling = %d, ",T[T[i].parent].leaf_l);
        else if(T[T[i].parent].leaf_r!=i && T[T[i].parent].leaf_r!=NIL)
            printf("sibling = %d, ",T[T[i].parent].leaf_r);

        if(T[i].leaf_l!=NIL) deg++;
        if(T[i].leaf_r!=NIL) deg++;

        printf("degree = %d, ",deg);

        cnt =  0;
        Npare = i;
        while(1){
            if(T[Npare].parent == NIL) break;
            Npare = T[Npare].parent;
            cnt++;
        }
        if(maxd<cnt) maxd = cnt;
        printf("depth = %d, ",cnt);

        printf("height = %d, ",Height_get(i));
        if(T[i].parent == NIL) printf("root");
        else if(deg > 0) printf("internal node");
        else if(deg == 0) printf("leaf");
        deg = 0;
        printf("\n");
    }
    return 0;
}

int Height_get(int u){
   int h1=0;
   int h2=0;
   if(T[u].leaf_l!=NIL)
     h1=Height_get(T[u].leaf_l)+1;
   if(T[u].leaf_r!=NIL)
     h2= Height_get(T[u].leaf_r)+1;
       if(h1>h2)return Height[u]=h1;
       else return Height[u]=h2;
}