#define _USE_MATH_DEFINES

#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>
#include <unordered_set>
#include <cmath>
#include <iomanip>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::getline(stream, buf);
		std::stringstream sstr(buf);

		std::vector<int> retval;
		retval.reserve(num);

		std::string input;;
		for (int i = 0; i < num && std::getline(sstr, input, delim); ++i)
		{
			retval.push_back(std::stoi(input));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename Itr>
	void PrintLine(Itr begin, Itr end)
	{
		bool first = true;

		for (int i = 0; begin != end; ++begin, ++i)
		{
			if (!first)
			{
				std::cout << ' ';
			}

			std::cout << (*begin);

			first = false;
		}
		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}

	const int kNil = -1;

	struct Node
	{
		int parent;
		int left;
		int right;

		Node()
			: parent(kNil)
			, left(kNil)
			, right(kNil)
		{}
	};

	Node node[25];
	int depth[25];
	int height[25] = {};

	void Depth(int num, int d)
	{
		depth[num] = d;
		if (node[num].left != kNil)
		{
			Depth(node[num].left, d + 1);
		}
		if (node[num].right != kNil)
		{
			Depth(node[num].right, d + 1);
		}
	}

	int Height(int num)
	{
		int left = 0;
		int right = 0;

		if (node[num].left != kNil)
		{
			left = Height(node[num].left) + 1;
		}

		if (node[num].right != kNil)
		{
			right = Height(node[num].right) + 1;
		}

		height[num] = std::max(left, right);

		return height[num];
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	int num = GetValue<1>(stream)[0];

	for (int i = 0; i < num; ++i)
	{
		auto t = GetValue<3>(stream);
		node[t[0]].left = t[1];
		node[t[0]].right = t[2];

		node[t[1]].parent = t[0];
		node[t[2]].parent = t[0];
	}

	int root_num = 0;
	for (int i = 0; i < num; ++i)
	{
		if (node[i].parent == kNil)
		{
			root_num = i;
			break;
		}
	}

	Depth(root_num, 0);
	height[root_num] = Height(root_num);

	for (int i = 0; i < num; ++i)
	{
		std::cout << "node " << i <<
			": parent = " << node[i].parent <<
			", sibling = ";

		if (node[i].parent != kNil)
		{
			if (node[node[i].parent].left != i)
			{
				std::cout << node[node[i].parent].left;
			}
			else
			{
				std::cout << node[node[i].parent].right;
			}
		}
		else
		{
			std::cout << -1;
		}

		std::cout << ", degree = ";
		int degree = 0;
		if (node[i].left != kNil)
			++degree;
		if (node[i].right != kNil)
			++degree;
		std::cout << degree;

		std::cout << ", depth = " << depth[i] <<
			", height = " << height[i];

		if (node[i].parent == kNil)
		{
			std::cout << ", root";
		}
		else if(node[i].left == kNil && node[i].right == kNil)
		{
			std::cout << ", leaf";
		}
		else
		{
			std::cout << ", internal node";
		}

		std::cout << std::endl;
	}
}



Measured memory_bytes: 3216