#include<cstdio>
#include<iostream>
#include<math.h>
#include<stdlib.h> 
using namespace std;
#define Max 100
#define nan -1
struct node{int p,l,r;};
int num;
node tree[Max];
int depth[Max];
int height[Max];
void cal_deep(int p,int u){
	depth[p]=u;
	if(tree[p].l!=nan) cal_deep(tree[p].l,u+1);
	if(tree[p].r!=nan) cal_deep(tree[p].r,u+1);
	return;
}
int  cal_height(int p){
	int h1=0;int h2=0;
	if(tree[p].r!=nan) h1=cal_height(tree[p].r)+1;
	if(tree[p].l!=nan) h2=cal_height(tree[p].l)+1;
	int h=max(h1,h2);
	height[p]=h;
    return h;
}
void print(){
	for(int i=0;i<num;i++){
		cout<<"node "<<i<<": parent = "<<tree[i].p<<", sibling = ";
		if(tree[i].p!=nan&&tree[tree[i].p].l!=i&&tree[tree[i].p].l!=nan) cout<<tree[tree[i].p].l;
		else if(tree[i].p!=nan&&tree[tree[i].p].r!=i&&tree[tree[i].p].r!=nan) cout<<tree[tree[i].p].r;
		else cout<<"-1";
		cout<<", degree = ";
		int degree=0;
		if(tree[i].l!=nan) degree++;
		if(tree[i].r!=nan) degree++;
		cout<<degree<<", depth = "<<depth[i]<<", height = "<<height[i]<<", ";
		string a;
		if(tree[i].p==nan) a="root";
		else if(tree[i].r==nan&&tree[i].l==nan) a="leaf";
		else a="internal node";
		cout<<a<<endl;
	}
}
int main(){
	scanf("%d",&num);
	for(int i=0;i<num;i++){tree[i].l=tree[i].r=tree[i].p=nan;}
	for(int i=0;i<num;i++){
		int v,l,r;
		scanf("%d %d %d",&v,&l,&r);
		if(r!=-1){tree[v].r=r;tree[r].p=v;}
		if(l!=-1){tree[v].l=l;tree[l].p=v;}
	}
	int root;
	for(int i=0;i<num;i++){
		if(tree[i].p==nan){
			root=i;break;
		}
	}
	cal_deep(root,0);
	cal_height(root);
	print();
}

