#include <stdio.h>
#include <stdlib.h>

typedef struct node {
    int parent, left, right;
} Node;

int n;
Node *nodes;

void printParent(int index) {
    printf("parent = %d, ", nodes[index].parent);
}

void printSiblig(int index) {
    int parent = nodes[index].parent;
    if (parent < 0) {
        printf("siblig = -1, ");
        return;
    }

    if (nodes[nodes[index].parent].left == index) {
        printf("siblig = %d, ", nodes[nodes[index].parent].right);
    } else {
        printf("siblig = %d, ", nodes[nodes[index].parent].left);
    }
}

void printDegree(int index) {
    int degree = 0;

    if (nodes[index].left != -1) degree++;
    if (nodes[index].right != -1) degree++;

    printf("degree = %d, ", degree);
}

int findDepth(int index, int target, int depth) {
    if (index == -1) {
        return 0;
    }

    if (index == target) {
        return depth;
    }

    return findDepth(nodes[index].left, target, depth + 1) + findDepth(nodes[index].right, target, depth + 1);
}

void printDepth(int index) {
    printf("depth = %d, ", findDepth(0, index, 0));
}

int calcHeight(int index) {
    int h1 = 0, h2 = 0;

    if (nodes[index].left != -1) {
        h1 = calcHeight(nodes[index].left) + 1;
    }

    if (nodes[index].right != -1) {
        h2 = calcHeight(nodes[index].right) + 1;
    }

    return h1 > h2 ? h1 : h2;
}

void printHeight(int index) {
    printf("height = %d, ", calcHeight(index));
}

void printPosition(int index) {
    if (nodes[index].parent == -1) printf("%s", "root");
    else if (nodes[index].left == -1 && nodes[index].right == -1) printf("%s", "leaf");
    else printf("%s", "internal node");
}

void printAnswer() {
    for (int i = 0; i < n; i++) {
        printf("node %d: ", i);
        printParent(i);
        printSiblig(i);
        printDegree(i);
        printDepth(i);
        printHeight(i);
        printPosition(i);
        printf("\n");
    }
}

int main() {
    scanf("%d\n", &n);

    nodes = (Node*)malloc(sizeof(Node) * n + 1);

    for (int i = 0; i < n; i++) nodes[i].parent = -1;

    int id, left, right;
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &id, &left, &right);

        // apply children
        nodes[i].left = left;
        nodes[i].right = right;

        // apply parent
        nodes[left].parent = i;
        nodes[right].parent = i;
    }

    printAnswer();

    return 0;
}

