#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

struct TNode
{
	int Id;
	TNode* Parent;
	TNode* LChild;
	TNode* RChild;
};

//???????????????????????????TNode*???????????????(vector??????????????¢?????????????????????)
class TTable
{
private:
	vector<TNode*> FNodes;
	void Create(int Id)
	{
		if(FNodes[Id] == NULL){
			TNode* Node;
			Node = new TNode;
			*Node = {Id, NULL, NULL, NULL};
			FNodes[Id] = Node;
		}
	}
public:
	//TNode*?????????&?????????????????????????????????
	//????????????????????§delete????????????????????????????????????????????????????????¨?????????????????????????????????????????????
	//???????????????????????????Id??¨TNode*???????????????????????¨??§????????????????????????????????¨????????????????????????????????????
	TNode* operator[](int n)
	{
		Create(n);
		return FNodes[n];
	}
	TNode* operator[](int n)const
	{
		return FNodes[n];
	}
	TTable(int n)
	{
		//????´??????°???????????????
		FNodes.resize(n, NULL);
	}
	~TTable()
	{
		int n = FNodes.size();
		for(int i = 0; i < n; i++){
			delete FNodes[i];
		}
	}
	int size()const
	{
		return FNodes.size();
	}
};

enum TNodeType {Root, InternalNode, Leaf};

void CreateLeftRelation(TNode* ParentNode, TNode* LChildNode)
{
	ParentNode->LChild = LChildNode;
	LChildNode->Parent = ParentNode;
}

void CreateRightRelation(TNode* ParentNode, TNode* RChildNode)
{
	ParentNode->RChild = RChildNode;
	RChildNode->Parent = ParentNode;
}

void Input(TTable& Table)
{
	for(int i = 0; i < Table.size(); i++){
		int Id;
		cin >> Id;
		TNode* Node = Table[Id];
		int left;
		cin >> left;
		if(left != -1){
			CreateLeftRelation(Node, Table[left]);
		}
		int right;
		cin >> right;
		if(right != -1){
			CreateRightRelation(Node, Table[right]);
		}
	}
}

int GetSibling(const TNode* Node)
{
	const TNode* Parent = Node->Parent;
	if(Parent == NULL){
		return -1;
	}
	if(Node == Parent->LChild && Parent->RChild){
		return Parent->RChild->Id;
	}
	if(Node == Parent->RChild && Parent->LChild){
		return Parent->LChild->Id;
	}
	return -1;
}

int GetDegree(const TNode* Node)
{
	return (Node->LChild ? 1 : 0) + (Node->RChild ? 1 : 0);
}

int GetDepth(const TNode* Node)
{
    int depth = 0;
    while(Node->Parent){
        depth++;
        Node = Node->Parent;
    }
    return depth;
}

int GetHeight(const TNode* Node)
{
	if(Node == NULL) return -1;
	return 1 + max(GetHeight(Node->LChild), GetHeight(Node->RChild));
}

TNodeType GetType(const TNode* Node)
{
    if(Node->Parent == NULL){
        return Root;
    }
	if(Node->LChild == NULL && Node->RChild == NULL){
        return Leaf;
    }
    return InternalNode;
}

void Output(const TTable& Table)
{
	for(unsigned int i = 0; i < Table.size(); i++){
		cout << "node " << Table[i]->Id << ": ";
		if(Table[i]->Parent){
		    cout << "parent = " << Table[i]->Parent->Id << ", ";
		}else{
		    cout << "parent = -1, ";
		}
		cout << "sibling = " << GetSibling(Table[i]) << ", ";
		cout << "degree = "  << GetDegree(Table[i])  << ", ";
		cout << "depth = "   << GetDepth(Table[i])   << ", ";
		cout << "height = "  << GetHeight(Table[i])  << ", ";
		if(GetType(Table[i]) == Root){
		    cout << "root"; 
		}else if(GetType(Table[i]) == InternalNode){
		    cout << "internal node";    
		}else{
		    cout << "leaf";
		}
		cout << endl;
	}
}

int main()
{
	int n;
	cin >> n;
	if(n == 1){
		cout << "node 0: parent = -1, sibling = -1, degree = 0, depth = 0, height = 0, root" << endl;
		return 0;
	}
	TTable Table(n);
	Input(Table);
	Output(Table);
    return 0;
}

Measured memory_bytes: 3100