#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

struct Node{
    int sib,p,k,left,right;
    Node(){
        sib=p=k=left=right=-1;
    }
};

int calcHeight(int id,Node* node,int height){
    if(id==-1)return -1;
    if(node[id].k==0)return height;
    if(height>25)return -1;
    else return max(calcHeight(node[id].left,node,height+1),calcHeight(node[id].right,node,height+1));
}

int main(void){
    int n,i,k,id,left,right,depth;
    Node node[25];
    
    cin>>n;

    for(i=0;i<n;i++){
        cin>>id>>left>>right;
        k=0;
        node[id].left=left;
        node[id].right=right;
        if(left!=-1){
            node[left].sib=right;
            node[left].p=id;
            k++;
        }
        if(right!=-1){
            node[right].sib=left;
            node[right].p=id;
            k++;
        }
        node[id].k=k;
    }
    
    for(i=0;i<n;i++){
        id=i;
        depth=0;
        for(int j=0;j<n;j++){
            if(node[id].p==-1)break;
            id=node[id].p;
            depth++;
        }
        /*
        while(node[id].p!=-1){
            id=node[id].p;
            depth++;
        }
        */
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
            i,node[i].p,node[i].sib,node[i].k,depth,calcHeight(i,node,0));
        if(depth==0)printf("root\n");
        else if(node[i].k>0)printf("internal node\n");
        else printf("leaf\n");
    }
    return 0;
}


