#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

class btree
{
public:
    btree() {}
    btree(int n)
    : p(vs32(n, -1)), l(vs32(n, -1)), r(vs32(n, -1)), d(vs32(n)), h(vs32(n, 0))
    {}
    ~btree() {}

    string status(int u)
    {
        if (p[u] < 0) return "root";
        else if (l[u] < 0 && r[u] < 0) return "leaf";
        else return "internal node";
    }

    int deg(int u)
    {
        int ret = 0;
        if (l[u] >= 0) ++ret;
        if (r[u] >= 0) ++ret;
        return ret;
    }

    int sib(int u)
    {
        int v = p[u];
        int cl = (v < 0 ? -1 : l[v]);
        int cr = (v < 0 ? -1 : r[v]);
        int ret = (u == cl) ? cr : cl;
        return ret;
    }

    void depth()
    {
        int root  = 0;
        while (p[root] >= 0) root = p[root];

        d[root] = 0;
        if (l[root] >= 0) setdepth(l[root], 1);
        if (r[root] >= 0) setdepth(r[root], 1);
    }

    void setdepth(int u, int de)
    {
        d[u] = de;
        if (l[u] >= 0) setdepth(l[u], de + 1);
        if (r[u] >= 0) setdepth(r[u], de + 1);
    }

    void height()
    {
        int root = 0;
        while (p[root] >= 0) root = p[root];

        int ll = l[root];
        int rr = r[root];
        if (ll >= 0)
        {
            h[root] = setheight(ll) + 1;
        }
        if (rr >= 0)
        {
            h[root] = MAX(h[root], setheight(rr) + 1);
        }
    }

    int setheight(int u)
    {
        int ll = l[u], rr = r[u];
        if (ll < 0 && rr < 0)
        {
            h[u] = 0;
        }
        else
        {
            if (ll >= 0)
            {
                h[u] = MAX(h[u], setheight(ll) + 1);
            }
            if (rr >= 0)
            {
                h[u] = MAX(h[u], setheight(rr) + 1);
            }
        }
        return h[u];
    }

    vs32 p;
    vs32 l;
    vs32 r;
    vs32 d;
    vs32 h;
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    btree bt(n);
    int p, l, r;
    rep (i, n)
    {
        cin >> p >> l >> r;
        if (p >= 0)
        {
            bt.l[p] = l;
            bt.r[p] = r;
        }
        if (l >= 0) bt.p[l] = p;
        if (r >= 0) bt.p[r] = p;
    }

    bt.depth();
    bt.height();

    rep (i, n)
    {
        cout << "node " << i << ": "
            << "parent = " << bt.p[i] << ", "
            << "sibling = " << bt.sib(i) << ", "
            << "degree = " << bt.deg(i) << ", "
            << "depth = " << bt.d[i] << ", "
            << "height = " << bt.h[i] << ", "
            << bt.status(i) << "\n";
    }
    return 0;
}




Measured memory_bytes: 3216