#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 200001
#define Max 10000
#define NTL -1
typedef struct{
    int p,left,right,state,depth,sibl,deg,hei;
}Node;
Node T[N];
int n;
char root[N];
void getDepth(int p,int d){
    T[p].depth=d;
    if(T[p].right != NTL) getDepth(T[p].right,d+1);
    if(T[p].left != NTL) getDepth(T[p].left,d+1);
}
int getHeight(int p){
    int a=0,b=0;
    if(T[p].left != NTL)a=getHeight(T[p].left)+1;
    if(T[p].right!=NTL)b=getHeight(T[p].right)+1;
    if(a<b) T[p].hei=b;
    else T[p].hei=a;
    return T[p].hei;
}
int main()
{
    int i,r;
    scanf("%d",&n);
    memset(root,1,n);
    for(i=0;i<n;i++){
        T[i].left=T[i].sibl=T[i].right=NTL;
    }
    for(i=0;i<n;i++){
        int id,l,r;
        scanf("%d%d%d",&id,&l,&r);
        if(l!=NTL){
            T[id].left=l;
            T[l].p=id;
        }
        if(r!=NTL){
            T[id].right=r;
            T[r].p=id;
        }
        if(l==NTL&&r==NTL){
            T[id].state=1;
            T[r].deg=0;
        }else if(l==NTL||r==NTL){
            T[id].state=2;
            T[id].deg=1;
        }else{
            T[id].state=2;
            T[id].deg=2;
            T[l].sibl=r;
            T[r].sibl=l;
        }
        root[l]=root[r]=0;
    }
    for(i=0;i<n;i++)
        if(root[i]) r=i;
    T[r].p = NTL;
    T[r].state=0;
    getDepth(r,0);
    getHeight(r);
    for(i=0;i<n;i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d,  height = %d, ",i,T[i].p,T[i].sibl,T[i].deg,T[i].depth,T[i].hei);
        if(T[i].state==0)printf("root\n");
        else if(T[i].state==1)printf("leaf\n");
        else if(T[i].state==2)printf("internal node\n");
    }
  return 0;
}
