#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
struct Tree{
    int me;
    int parent;
    int bro;
    int numChild;
    int left;
    int right;
    int dep;
    int high;
    string type;
};

void calcDepth(vector<Tree> &tree,int now,int parentDepth){
    tree[now].dep = parentDepth+1;
    if(tree[now].left != -1) calcDepth(tree,tree[now].left,tree[now].dep);
    if(tree[now].right != -1) calcDepth(tree,tree[now].right,tree[now].dep);
}

void otherBro(vector<Tree> &tree, int now, int oth){
    if(oth != -1) tree[now].bro = oth;
    if(tree[now].left == -1 && tree[now].right == -1) return;
    if(tree[now].left != -1 && tree[now].right != -1){
        otherBro(tree,tree[now].left,tree[now].right);
        otherBro(tree,tree[now].right,tree[now].left);
    }
    if(tree[now].left != -1){
        otherBro(tree,tree[now].left,tree[now].right);
    }
    if(tree[now].right != -1){
        otherBro(tree,tree[now].right,tree[now].left);
    }
    return;
}
int checkHigh(vector<Tree> &tree,int now){
    int mhr=-1,mhl=-1;
    if(tree[now].left != -1) mhl = checkHigh(tree,tree[now].left);
    if(tree[now].right != -1) mhr  = checkHigh(tree,tree[now].right);
    tree[now].high = max(mhl,mhr)+1;
    return tree[now].high;

}

bool cmp(const Tree &a, const Tree &b){
    return a.me < b.me;
}

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<Tree> tree(n);
    int l,r;
    for(int i = 0; i < n;i++){
        cin >> tree[i].me;
        cin >> l  >> r;
        if(l != -1 && r != -1){
            tree[i].numChild = 2;
            tree[i].type = "internal node";
        }else if(l == -1 && r == -1){
            tree[i].numChild = 0;
            tree[i].type = "leaf";
        }else{
            tree[i].numChild = 1;
            tree[i].type = "internal node";
        }
        tree[i].left  = l;
            tree[i].right  = r;
        tree[i].parent = -1;
        tree[i].bro = -1;
    }

    sort(ALL(tree),cmp);
    for(int i = 0; i < n;i++){
        if(tree[i].left != -1){
            tree[tree[i].left].parent = tree[i].me;
        }
        if(tree[i].right != -1){
            tree[tree[i].right].parent = tree[i].me;
        }
    }

    for(int i = 0; i < n;i++){
        if(tree[i].parent == -1){
            tree[i].type = "root";
            calcDepth(tree,tree[i].me,-1);
            otherBro(tree,tree[i].me,-1);
            checkHigh(tree,tree[i].me);
        }
    }

    for(int i = 0; i < n;i++){
        cout << "node " <<  tree[i].me << ": parent = " << tree[i].parent << 
        ", sibling = " << tree[i].bro << ", degree = " << tree[i].numChild <<
        ", depth = " << tree[i].dep << ", height = " << tree[i].high << ", " << tree[i].type << endl;
    }
    
    
    

    

    return 0;
}


Measured memory_bytes: 3224