#include <iostream>
#include <string>
 
using namespace std;
 
class Node{
    public:
        int l, r, p;
        int deg, sib, dep, hig;
        string typ;
};
Node nodes[25];
 
int top(int id,int tp){
    if(nodes[id].p!=-1){
        return top(nodes[id].p,tp+1);
    }
    return tp;
}
 
 
int dfs(int id,int dep){
    if(nodes[id].r!=-1||nodes[id].l!=-1){
      int m=0;
      if(nodes[id].r!=-1)
          m = dfs(nodes[id].r,dep+1);
      if(nodes[id].l!=-1)
          m = max(m,dfs(nodes[id].l,dep+1));
      return m;
    }
    return dep;
}
 
int main(){
    int n, id, r, l;
    int parent;
    cin>>n;
    for(int i=0;i<n;i++){
        nodes[i].p=-1;
        nodes[i].sib=-1;
        nodes[i].dep= -1;
        nodes[i].typ = "";
    }
             
    for(int i=0;i<n;i++){
        bool flag=true;
        cin>>id>>r>>l;
        if(r!=-1){
            nodes[ r].p = id;
            nodes[id].r = r;
            nodes[id].deg = 1;
            flag=false;
        }else{
            nodes[id].r = -1;
        }
        if(l!=-1){
            nodes[ l].p = id;
            nodes[id].l = l;
            nodes[id].deg = 1;
            flag=false;
        }else{
            nodes[id].l = -1;
        }
        if(r!=-1&&l!=-1){
            nodes[ l].sib = r;
            nodes[ r].sib = l;
            nodes[id].deg = 2;
        }
        if(flag)
            nodes[id].typ="leaf";
        else
            nodes[id].typ="internal node";
    }
    for(int i=0;i<n;i++){
        if(nodes[i].p==-1){
            nodes[i].typ = "root";
        }
        nodes[i].hig=dfs(i,0);
        nodes[i].dep=top(i,0);
    }
    for(int i=0;i<n;i++){
        cout<<"node "<<i;
        cout<<": parent = "<<nodes[i].p;
        cout<<", sibling = "<<nodes[i].sib;
        cout<<", degree = "<<nodes[i].deg;
        cout<<", depth = "<<nodes[i].dep;
        cout<<", height = "<<nodes[i].hig;
        cout<<", "<<nodes[i].typ;
        cout<<endl;
    }
     
 
    return 0;
}