#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

class Tree {
    private:
    typedef struct Node {
        int parent;
        int left;
        int right;
        Node() : parent(-1), left(-1), right(-1) {}
    } Node;
    int m_root;
    vector<Node> m_node;
    vector<int> m_depth;
    vector<int> m_height;

    public:
    Tree(int n) : m_root(-1), m_node(n), m_depth(n, 0), m_height(n, 0) {
        for (int i = 0; i < n; i++) {
            m_node[i].parent = -1;
            m_node[i].left= -1;
            m_node[i].right= -1;
        }
    }
    ~Tree(){}

    void SetParent(int node, int parent) {
        m_node[node].parent = parent;
    }

    void SetLeftRight(int node, int left, int right) {
        m_node[node].left = left;
        m_node[node].right = right;
    }

    void SetRoot() {
        for (int i = 0; i < m_node.size(); i++) {
            if (m_node[i].parent == -1) {
                m_root = i;
                return;
            }
        }
    }

    void Print() {
        for (int i = 0; i < m_node.size(); i++) {
            PrintNode(i);
        }
    }

    void PrintNode(int node) {
        printf("node %d: parent = %d", node, m_node[node].parent);
        PrintSibling(node);
        PrintDegree(node);
        printf(", depth = %d", m_depth[node]);
        printf(", height = %d", m_height[node]);
        PrintType(node);
        printf("\n");
    }

    void PrintSibling(int node) {
        int parent = m_node[node].parent;
        if (parent == -1) {
            printf(", sibling = -1");
            return;
        }
        int left = m_node[parent].left;
        int right = m_node[parent].right;
        if (left != node) {
            printf(", sibling = %d", left);
        } else {
            printf(", sibling = %d", right);
        }
    }

    void PrintDegree(int node) {
        int left = m_node[node].left;
        int right = m_node[node].right;
        int deg = 0;
        if (left != -1) {
            deg++;
        }
        if (right != -1) {
            deg++;
        }
        printf(", degree = %d", deg);
    }

    void SetDepth() {
        SetDepthNode(m_root, 0);
    }

    void SetDepthNode(int node, int depth) {
        if (node == -1) {
            return;
        }
        m_depth[node] = depth;
        if (m_node[node].left != -1) {
            SetDepthNode(m_node[node].left, depth + 1);
        }
        if (m_node[node].right != -1) {
            SetDepthNode(m_node[node].right, depth + 1);
        }
        return;
    }

    void SetHeight() {
        SetHeightNode(m_root);
    }

    int SetHeightNode(int node) {
        int h1 = 0;
        int h2 = 0;
        if (m_node[node].left != -1) {
            h1 = SetHeightNode(m_node[node].left) + 1;
        }
        if (m_node[node].right != -1) {
            h2 = SetHeightNode(m_node[node].right) + 1;
        }
        return m_height[node] = max(h1, h2);
    }

    void PrintType(int node) {
        if (m_node[node].parent == -1) {
            printf(", root");
            return;
        }
        if (m_node[node].left == -1 && m_node[node].right == -1) {
            printf(", leaf");
            return;
        } else {
            printf(", internal node");
            return;
        }
    }
};

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

    Tree tree(n);

    for (int i = 0; i < n; i++) {
        int id, left, right;
        cin >> id >> left >> right;
        tree.SetLeftRight(id, left, right);
        tree.SetParent(left, id);
        tree.SetParent(right, id);
    }

    tree.SetRoot();
    tree.SetDepth();
    tree.SetHeight();
    tree.Print();

    return 0;
}



Measured memory_bytes: 3208