#include<iostream>
using namespace std;
const int MAX=10005;
const int NIL=-1;
int l[MAX],r[MAX],p[MAX],s[MAX],d[MAX],height[MAX];
void print(int i)
{
    cout<<"node "<<i<<": ";
    int x=0;
    if(l[i]!=NIL)x++;
    if(r[i]!=NIL)x++;
    cout<<"parent = "<<p[i]<<", sibling = "<<s[i];
    cout<<", degree = "<<x<<", depth = "<<d[i];
    cout<<", height = "<<height[i];
    cout<<", ";
    if(p[i]==NIL)cout<<"root";
    else if(x==0)cout<<"leaf";
    else cout<<"internal node";
        cout<<endl;
}
void setD(int i,int t)
{
    if(i==NIL)return ;
    d[i]=t;
    setD(l[i],t+1);
    setD(r[i],t+1);
}
int setH(int i)
{
    int h1=0,h2=0;
    if(l[i]!=NIL)
        h1=setH(l[i])+1;
    if(r[i]!=NIL)
        h2=setH(r[i])+1;
    return height[i]=max(h1,h2);
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)p[i]=l[i]=r[i]=s[i]=NIL;

    for(int i=0;i<n;i++)
    {
        int v=0;
        cin>>v;
        cin>>l[v]>>r[v];
        s[l[v]]=r[v],s[r[v]]=l[v];
        if(l[v]!=NIL)p[l[v]]=v;
        if(r[v]!=NIL)p[r[v]]=v;
    }
    int root=0;
    for(int i=0;i<n;i++)if(p[i]==NIL)root=i;
    if(root==-1)cout<<"error"<<endl;
    else
    {
        setD(root,0);
        setH(root);
    }
    for(int i=0;i<n;i++)print(i);
    return 0;
}

