#include<cstdio>
#define N 10000
#define NIL -1

struct Node {int p,l,r;};

Node TW[N];
int n, DT[N],HG[N];

void setDepth(int u,int p){
    if (u == NIL)return;
    DT[u] = p;
    setDepth(TW[u].r,p+1);
    setDepth(TW[u].l,p+1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(TW[u].l != NIL)h1=setHeight(TW[u].l)+1;
    if(TW[u].r != NIL)h2=setHeight(TW[u].r)+1;
    return HG[u] = (h1>h2?h1:h2);
}

int getSibling(int u){
    if (TW[u].p == NIL) return NIL;
    if(TW[TW[u].p].l != u && TW[TW[u].p].l != NIL)return TW[TW[u].p].l;
    if(TW[TW[u].p].r != u && TW[TW[u].p].r != NIL)return TW[TW[u].p].r;
    return NIL;
}

void print(int u){
    printf("node %d: ", u);
    printf("parent = %d, ", TW[u].p);
    printf("sibling = %d, ",getSibling(u));
    int deg = 0;
    if(TW[u].l != NIL)deg++;
    if(TW[u].r != NIL)deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", DT[u]);
    printf("height = %d, ", HG[u]);

    if (TW[u].p == NIL){
     printf("root\n");
    }
    else if (TW[u].l == NIL && TW[u].r == NIL){
     printf("leaf\n");
    }
    else{
     printf("internal node\n");
    }
}

int main(){
    int v,l,r,root=0;
    scanf("%d" , &n);
    for(int i=0;i<n;i++)TW[i].p = NIL;

    for(int i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        TW[v].l =l;
        TW[v].r =r;
        if (l != NIL) TW[l].p =v;
        if (r != NIL) TW[r].p =v;
    }

    for(int i=0;i<n;i++){
        if(TW[i].p == NIL)root=i;  
    }

    setDepth(root,0);
    setHeight(root);

    for(int i=0;i<n;i++)print(i);

    return 0;
}

