#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;

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

P T[30];

int D[30], H[30];

void depth(int v, int d){
    if(v == -1) return;
    D[v] = d;
    depth(T[v].l, d + 1);
    depth(T[v].r, d + 1);
}
int hight(int v){
    if(v == -1) return -1;
    if(T[v].l == -1 && T[v].r == -1) H[v] = 0;
    return H[v] = (max(hight(T[v].l), hight(T[v].r)) + 1);
}

int sibling(int v){
    if(T[v].p == -1) return -1;
    if(T[T[v].p].l != v) return T[T[v].p].l;
    return T[T[v].p].r;
}

void print(int v){
    printf("node %d: ", v);
    printf("parent = %d", T[v].p);
    printf(", sibling = %d", sibling(v));
    int deg=0;
    if(T[v].l != -1) deg++;
    if(T[v].r != -1) deg++;
    printf(", degree = %d", deg);
    printf(", depth = %d", D[v]);
    printf(", height = %d", H[v]);
    if(T[v].p == -1) printf(", root\n");
    else if(T[v].l == -1&& T[v].r == -1) printf(", leaf\n");
    else printf(", internal node\n");
}

int main(){
    int n, v, l, r, root;
    cin >> n;
    for(int i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = -1;
    for(int i = 0; i < n; i++){
        cin >> v >> l >> r;
        T[v].l = l;
        T[v].r = r;
        if(l != -1) T[l].p = v;
        if(r != -1) T[r].p = v;
    }
    for(int i = 0; i < n; i++){
        if(T[i].p == -1) root = i;
    }
    depth(root, 0);
    hight(root);
    for(int i = 0; i < n; i++) print(i);
     
    
    
  return 0;
}
