#include<cstdio>
#include<set>
#include<iostream>
#include <iterator>
#include <utility>
#include<map>
#define max 100005
using namespace std;
struct tree
{
	int parent;
	int left;
	int  right;
};
struct tree T[30];
int dep(int i)
{
	int d=0;
	while(T[i].parent!=-1)
	{
		i=T[i].parent;
		d++;
	}
	return d;
}
int sib(int i)
{
	if(T[i].parent==-1)
	return -1;
	int x;
	x=T[i].parent;
	if(i==T[x].left)
	return T[x].right;
	else
	return T[x].left;
}
int deg(int i)
{
	if(T[i].right==-1&&T[i].left==-1)
	return 0;
	else if(T[i].right>=0&&T[i].left>=0)
	return 2;
	else
	return 1;
}
int h(int i)
{
	int a=0,b=0;
	if(T[i].left!=-1)
	a=h(T[i].left)+1;
	if(T[i].right!=-1)
	b=h(T[i].right)+1;
	return (a>b)? a:b;
}
void print(int i)
{
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,T[i].parent,sib(i),deg(i),dep(i),h(i));
	if(T[i].parent==-1)
	cout<<"root";
	else if(T[i].left==-1&&T[i].right==-1)
	cout<<"leaf";
	else
	cout<<"internal node";
	printf("\n");
}
int main()
{
	int n;
	int id,left,right;
	cin>>n;
	for(int i=0;i<n;i++)
	T[i].parent=-1;
	for(int i=0;i<n;i++)
	{
		int id,r,l;
		cin>>id>>l>>r;
		T[id].left=l;
		T[id].right=r;
		if(l!=-1)
		T[l].parent=id;
		if(r!=-1)
		T[r].parent=id;
	}
	for(int i=0;i<n;i++)
	print(i);
	return 0;
}
