#include<stdio.h>
 
const int A=100000;
const int B=-1;
struct node{
    int p,right,left,depth,height,sibling;
};
node Tree[A];
 
int iroiro(int p,int deep){
    if(Tree[p].left==B&&Tree[p].right==B){
        Tree[p].depth=deep;
        Tree[p].height=0;
        return 1;
    }else{
        int h1=-1,h2=-1,h3;
        if(Tree[p].left!=B){
	  h1=iroiroTree[p].left,deep+1);
    }
    if(Tree[p].right!=B){
	  h2=iroiro(Tree[p].right,deep+1);
    }
        h3=h1>h2?h1:h2;
        Tree[p].height=h3;
        Tree[p].depth=deep;
        return h3+1;
    }
} 
  
void dasu(int n){
    for(int i=0;i<n;i++){
        printf("node %d: parent = %d, sibling = %d, ",i,Tree[i].p,Tree[i].sibling);
        int degree=(Tree[i].left!=-1)+(Tree[i].right!=-1);
        printf("degree = %d, depth = %d, height = %d, ",degree,Tree[i].depth,Tree[i].height);
        if(Tree[i].p==-1){
            printf("root\n");
        }else if(degree==0){
            printf("leaf\n");
        }else{
            printf("internal node\n");
        }
    }
}
 
int main(){
    int n,l=n1,r=n2,no=n3;
    scanf("%d",&n);
    for(int i=0;i<n;i++)Tree[i].p=Tree[i].sibling=B;
    for(int i=0;i<n;i++){
        scanf("%d %d %d",&n3,&n1,&n2);
        Tree[n3].left=n1;
        Tree[n3].right=n2;
        Tree[n1].p=Tree[n2].p=n3;
        Tree[n1].sibling=n2;
        Tree[n2].sibling=n1;
    }
    int p=0;
    for(int i=0;i<n;i++)if(Tree[i].p==B)p=i;
    int x=iroiro(p,0);
    dasu(n);
}