#include <iostream>
#include <algorithm>
using namespace std;

struct node {
    node():p(-1),s(-1),l(-1),r(-1),d(-1),h(-1){}
    int p, s, l, r, d, h;
};

int setdh(node t[], int id, int d) {
    if(id==-1) return 0;
    t[id].d=d;
    t[id].h=max(setdh(t, t[id].l, d+1), setdh(t, t[id].r, d+1));
    return t[id].h+1;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    node t[25];
    cin>>n;
    for(int i=0; i<n; i++) {
        int id, l, r;
        cin>>id>>l>>r;
        t[id].l=l;
        t[id].r=r;
        if(l!=-1) t[l].p=id;
        if(r!=-1) t[r].p=id;
        if(l!=-1&&r!=-1) {
            t[l].s=r;
            t[r].s=l;
        }
    }
    int root;
    for(root=0; root<n&&t[root].p!=-1; root++);
    setdh(t, root, 0);
    for(int i=0; i<n; i++) {
        int deg = 0;
        if(t[i].l!=-1) deg++;
        if(t[i].r!=-1) deg++;
        const char *type;
        if(t[i].p==-1) type=", root\n";
        else if(deg==0) type=", leaf\n";
        else type=", internal node\n";
        cout<<"node "<<i<<": parent = "<<t[i].p<<", sibling = "<<t[i].s<<", degree = "<<deg<<", depth = "<<t[i].d<<", height = "<<t[i].h<<type;
    }
    return 0;
}