#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>


using namespace std;

//#define FILE_INPUT_DEBUG

class Tree;

class Node {
public:
	enum KindOfNode {
		ROOT, LEAF, INTERNAL
	};
	Node(Tree* tree);
	Tree* tree;
	int parent, left, right;
	int depth;//cache
	int height;//cache
	string kind;
	string getKind() const;
	int getSibling()const;
	int getDeg()const;
};

class Tree {
public:
	vector<Node> nodes;
	template<typename T>
	void init(T& cin) {
		int n;
		cin >> n;
		nodes.resize(n, Node(this));
		for (int i = 0; i != n; ++i) {
			int id; cin >> id;
			Node& node = nodes.at(id);
			cin >> node.left;
			cin >> node.right;
			if (node.left != -1) {
				nodes.at(node.left).parent = id;
			}
			if (node.right != -1) {
				nodes.at(node.right).parent = id;
			}
		}

		const int rootNodeID = distance(nodes.begin(), find_if(nodes.begin(), nodes.end(), [](const Node& node) {return node.parent == -1; }));
		function<void(int, int)> setDepth = [&](const int nodeID, const int d) {
			Node& targetNode = nodes.at(nodeID);
			targetNode.depth = d;
			if (targetNode.left != -1) setDepth(targetNode.left, d + 1);
			if (targetNode.right != -1) setDepth(targetNode.right, d + 1);
		};
		setDepth(rootNodeID, 0);

		function<int(int)> setHeight = [&](const int nodeID) {
			if (nodeID == -1)return -1;
			Node& targetNode = nodes.at(nodeID);
			const int heightL = setHeight(targetNode.left);
			const int heightR = setHeight(targetNode.right);
			const int myheight = max(heightL, heightR) + 1;
			targetNode.height = myheight;
			return myheight;
		};
		setHeight(rootNodeID);

	}
	void printNodesInfo()const;
};

Node::Node(Tree* treePtr) : tree(treePtr), parent(-1), left(-1), right(-1){}

string Node::getKind() const {
	if (parent == -1)return "root";
	if (left != -1 || right != -1)return "internal node";
	return "leaf";
}
int Node::getSibling()const {
	if (parent == -1)return -1;
	const Node& parentNode = tree->nodes.at(parent);
	const int id = distance(&tree->nodes.front(), const_cast<Node*>(this));
	return parentNode.right == id ? parentNode.left : parentNode.right;
}
int Node::getDeg()const {
	int deg = 0;
	if (left != -1)++deg;
	if (right != -1)++deg;
	return deg;
}

void Tree::printNodesInfo()const {
	const size_t n = nodes.size();
	for (size_t i = 0; i != nodes.size(); ++i) {
		const Node& node = nodes.at(i);//getSibling
		cout << "node " << i
			<< ": parent = " << node.parent
			<< ", sibling = " << node.getSibling()
			<< ", degree = " << node.getDeg()
			<< ", depth = " << node.depth 
			<< ", height = " << node.height
			<< ", " << node.getKind()
			<< endl;
	}
}

#ifdef FILE_INPUT_DEBUG
string getModulePath(){return __argv[0];}
string getCurrentDirectory(){
	const string modulePath = getModulePath();
	return modulePath.substr(0, modulePath.find_last_of("\\"));
}//最後に"\"は無い

string createFilePathInCurrentDirectory(const string& fileName) {
	const string currentDirectory = getCurrentDirectory();
	return currentDirectory + "\\" + fileName;
}
string getInputTextPath(){
	const string filePath("commandLineInput.txt");
	return createFilePathInCurrentDirectory(filePath);
}
#endif


int main()
{

	Tree tree;
	tree.init(cin);
	tree.printNodesInfo();


	


	return 0;
}


Measured memory_bytes: 3180