#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

int main() {
    int N;
    cin >> N;

    vector<vector<int>> ch(N);
    vector<int> par(N, -1);
    vector<int> sibling(N, -1);

    for (int i = 0; i < N; ++i) {
        int v, l, r;
        cin >> v >> l >> r;
        if (l >= 0) {
            par[l] = v;
            sibling[l] = r;
            ch[v].push_back(l);
        }
        if (r >= 0) {
            par[r] = v;
            sibling[r] = l;
            ch[v].push_back(r);
        }
    }

    int r = min_element(par.begin(), par.end()) - par.begin();
    vector<int> dep(N), h(N);

    function<int(int, int)> dfs = [&](int v, int d) -> int {
        dep[v] = d;
        h[v] = 0;
        for (int sv : ch[v]) {
            h[v] = max(h[v], dfs(sv, d + 1) + 1);
        }
        return h[v];
    };
    dfs(r, 0);

    for (int v = 0; v < N; ++v) {
        cout << "node " << v
             << ": parent = " << par[v]
             << ", sibling = " << sibling[v]
             << ", degree = " << ch[v].size()
             << ", depth = " << dep[v]
             << ", height = " << h[v]
             << ", ";
        cout << (par[v] < 0 ? "root" : (ch[v].empty() ? "leaf" : "internal node")) << endl;
    }
    return 0;
}

