#include <climits>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <sstream>
#include <string>
using namespace std;

#define MAX 100001
#define NIL -1



void print(vector<int> &v) {
    int n = (int)v.size();

    for (int i = 0; i < n; ++i)
    {
        cout << v[i];
        if(i < n - 1) {
            cout << " ";
        }
    }
    cout << endl;
}




struct node {
    int parent;
    int left;
    int right;
};

int n;
node T[MAX];


int getDepth(int node_number) {
    //親の番号を取得
    int parent_number = T[node_number].parent;

    //親がないときは終了
    if(parent_number == NIL) {
        return 0;
    }

    //親を伝って根の方向へ登っていく
    int depth = 0;
    while(parent_number != NIL) {
        //1つ上へ登る
        parent_number = T[parent_number].parent;
        depth++;
    }

    return depth;
}

int getHeight(int node_number) {
    node u = T[node_number];

    //子がいないときは終了
    if(u.left == NIL && u.right == NIL) {
        return 0;
    }

    //左右の高さをそれぞれ調べる
    int left_height  = 0;
    int right_height = 0;
    if(u.left  != NIL) left_height  = getHeight(u.left)  + 1;
    if(u.right != NIL) right_height = getHeight(u.right) + 1;

    //左右どちらか大きい方を選択
    return max(left_height, right_height);
}

int getSibling(int node_number) {
    int parent_number = T[node_number].parent;
    if(parent_number == NIL) { //親がいないときはrootなので兄弟もいない
        return NIL;
    }

    node parent = T[parent_number];

    //親のleftが自分自身のときは、親のrightが兄弟
    if(parent.left == node_number && parent.right != NIL) {
        return parent.right;
    }

    //親のrightが自分自身のときは、親のleftが兄弟
    if(parent.right == node_number && parent.left != NIL) {
        return parent.left;
    }

    //兄弟なし
    return  NIL;
}

int getDegree(int node_number) {
    int count = 0;

    node parent = T[node_number];
    if(parent.left  != NIL) count++;
    if(parent.right != NIL) count++;

    return count;

}


void printChildren(int node_number) {
    node parent = T[node_number];

    vector<int> children;
    if(parent.left != NIL) {
        children.push_back(parent.left);
    }
    if(parent.right != NIL) {
        children.push_back(parent.right);
    }

    //子がいないとき
    if(children.size() == 0) {
        return;
    }

    //子が1つのとき
    if(children.size() == 1) {
        cout << children[0];
        return;
    }

    //子が2つのとき
    printf("%d, %d", children[0], children[1]);
}


//ノードの種類を判定する
void checkType(int node_number) {
    node u = T[node_number];

    //親がないときは　root
    if(u.parent == NIL) {
        cout << "root";
        return;
    }

    //子供がないときは leaf
    if(u.left == NIL && u.right == NIL) {
        cout << "leaf";
        return;
    }

    //rootでもleafでもないときはinternal node
    cout << "internal node";
}


//出力
void out(int node_number) {
    printf("node %d: ", node_number);
    printf("parent = %d, ", T[node_number].parent);
    printf("sibling = %d, ", getSibling(node_number));
    printf("degree = %d, ", getDegree(node_number));
    printf("depth = %d, ", getDepth(node_number));
    printf("height = %d, ", getHeight(node_number));
    checkType(node_number);

    cout << endl;
}




int main(void) {
    cin >> n;

    //初期化
    for (int i = 0; i < n; ++i)
    {
        node u;
        u.parent = NIL;
        u.left   = NIL;
        u.right  = NIL;
        T[i] = u;
    }

    //入力
    for (int i = 0; i < n; ++i)
    {
        int id;
        int left;
        int right;
        cin >> id >> left >> right;

        //自分の子を設定
        T[id].left  = left;
        T[id].right = right;

        //子に親を設定
        if(left != NIL) {
            T[left].parent = id;
        }
        if(right != NIL) {
            T[right].parent = id;
        }
    }


    for (int i = 0; i < n; ++i)
    {
        out(i);
    }

    return 0;
}



Measured memory_bytes: 3192