#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int MAX_N = 30;
struct BinaryTree
{
    int parent = -1, sibling;
    int degree = 0, left, right;
    int depth, height;
};
vector<BinaryTree> T(MAX_N);
void SetDepth(int u, int d)
{
    T[u].depth = d;
    if(T[u].left != -1) SetDepth(T[u].left, d + 1);
    if(T[u].right != -1) SetDepth(T[u].right, d + 1);
}
int SetHeight(int u)
{
    T[u].height = max(T[u].left == -1 ? 0 : SetHeight(T[u].left), T[u].right == -1 ? 0 : SetHeight(T[u].right));
    return T[u].height + 1;
}
int main()
{
    int n; cin >> n;
    for(int i = 0; i < n; i++)
    {
        int node, l, r;
        cin >> node >> l >> r;
        T[node].left = l;
        T[node].right = r;
        T[l].parent = node, T[r].parent = node;
        T[l].sibling = r, T[r].sibling = l;
        if(l != -1) T[node].degree++;
        if(r != -1) T[node].degree++;
    }
    int root = -1;
    for(int node = 0; node < n; node++) if(T[node].parent == -1) root = node, T[node].sibling = -1;
    SetDepth(root, 0);
    SetHeight(root);
    for(int node = 0; node < n; node++)
    {
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", node, T[node].parent, T[node].sibling, T[node].degree, T[node].depth, T[node].height); 
        if(T[node].parent == -1) cout << "root";
        else if(T[node].degree != 0) cout << "internal node";
        else cout << "leaf";
        cout << endl;
    }
    return 0;
}
