#include<stdio.h>
#include<stdlib.h>
#define MAX 25
#define NIL -1

struct node {
    int p, l, r;
};

struct node Node[MAX];
int D[MAX];
int S[MAX];

int max(int a, int b){
    if (a > b) return a;
    else return b;
}

int setHeight(int u){
    int v1, v2;
    if(Node[u].l != NIL){
        v1 = setHeight(Node[u].l);
    } else if(Node[u].r != NIL){
        v2 = setHeight(Node[u].r);
    } else{
        return 0;
    }
    return 1 + max(v1, v2);
}

void setDepth(int u, int p){
    D[u] = p;
    if(Node[u].l != NIL){
        setDepth(Node[u].l, p + 1);
    } 
    if (Node[u].r != NIL){
        setDepth(Node[u].r, p+1);
    }
}

void num_sibling(int u){
    if(Node[u].p != NIL){
        int p = Node[u].p;
        if(Node[p].l != NIL && Node[p].l != u) S[u] = Node[p].l;
        else if(Node[p].r != NIL && Node[p].r != u) S[u] = Node[p].r;
        else S[u] = -1;
    } else{
        S[u] = -1;
    }
}

int cnt_children(int u){
    int cnt = 0;
    if(Node[u].l != NIL) cnt+=1;
    if(Node[u].r != NIL) cnt+=1;

    return cnt;
}

void print(int u){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
    u, Node[u].p, S[u], cnt_children(u) ,D[u], setHeight(u));

    if(Node[u].p == NIL) printf("root\n");
    else if(cnt_children(u) > 0) printf("internal node\n");
    else printf("leaf\n");
}

int main(){
    int n, i;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        Node[i].l = Node[i].r = Node[i].p = NIL;
    }

    for(i = 0; i < n; i++){
        int id, c1, c2;
        scanf("%d%d%d", &id, &c1, &c2);
        Node[id].l = c1;
        Node[id].r  =c2;

        if(c1 != NIL) Node[c1].p = id;
        if(c2 != NIL) Node[c2].p = id;

    }

    int root;
    for(i = 0; i < n; i++) {
        if(Node[i].p == NIL) root = i;
    }

    
    setDepth(root, 0);

    for(i = 0; i < n; i++) print(i);
    return 0;
}
