#include <stdio.h>
#define MAX 10001
#define B -1

typedef struct {
        int parent,left,right;
}Bi;
Bi Node[MAX];

int getSibling(int);
int setHeight(int);
void setDepth(int,int);
void print(int);
int n, D[MAX], H[MAX];

int main(){
        int i,v,l,r, root=0;
        scanf("%d",&n);

        for(i=0; i<n; i++) {
                Node[i].parent=B;
        }

        for(i=0; i < n; i++) {
                scanf("%d%d%d",&v,&l,&r);
                Node[i].left=l;
                Node[i].right=r;
                if(l!=B) Node[l].parent=v;
                if(r!=B) Node[r].parent=v;
        }

        for(i=0; i<n; i++) {
                if(Node[i].parent == B) root = i;
        }
        setDepth(root, 0);
        setHeight(root);

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


int getSibling(int i){
        if(Node[i].parent==B) {return B;}
        if(Node[Node[i].parent].left != i && Node[Node[i].parent].left != B) {
                return Node[Node[i].parent].left;
        }
        if(Node[Node[i].parent].right != i && Node[Node[i].parent].right != B) {
                return Node[Node[i].parent].right;
        }
        return B;
}
void setDepth(int u, int d){
        if(u==B) return;
        D[u]=d;
        setDepth(Node[u].left, d+1);
        setDepth(Node[u].right,d+1);
}

int setHeight(int i){
        int h1=0,h2=0;
        if(Node[i].left!=B) h1=setHeight(Node[i].left)+1;
        if(Node[i].right!=B) h2=setHeight(Node[i].right)+1;
        return H[i]=(h1 > h2 ? h1 : h2);
}

void print(int u){
        printf("node %d: ", u);
        printf("parent = %d, ", Node[u].parent);
        printf("sibling = %d, ", getSibling(u));
        int deg=0;
        if(Node[u].left != B) deg++;
        if(Node[u].right != B) deg++;
        printf("degree = %d, ", deg);
        printf("depth = %d, ", D[u]);
        printf("height = %d, ", H[u]);

        if(Node[u].parent == B) {
                printf("root\n");
        }else if (Node[u].left ==B && Node[u].right == B) {
                printf("leaf\n");
        }else {
                printf("internal node\n");
        }
}