#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;
	}

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

		Node()
			: parent(-1)
			, left(-1)
			, right(-1)
		{}
	};

	Node node[100000];
	int depth[100000];

	void Depth(int n, int d)
	{
		depth[n] = d;
		if (node[n].right != -1)
		{
			Depth(node[n].right, d);
		}

		if (node[n].left != -1)
		{
			Depth(node[n].left, d + 1);
		}
	}

	void Print(int n)
	{
		std::cout << "node " << n <<
			": parent = " << node[n].parent <<
			", depth = " << depth[n] << ", ";

		if (node[n].parent == -1)
		{
			std::cout << "root, ";
		}
		else if (node[n].left == -1)
		{
			std::cout << "leaf, ";
		}
		else
		{
			std::cout << "internal node, ";
		}

		std::cout << "[";

		bool first = true;
		for (int child = node[n].left; child != -1; child = node[child].right)
		{
			if (!first)
			{
				std::cout << ", ";
			}
			first = false;
			std::cout << child;
		}

		std::cout << "]" << std::endl;
	}
}

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];

	int n, degree, child, left = 0;

	for (int i = 0; i < num; ++i)
	{
		stream >> n;
		stream >> degree;
		for (int j = 0; j < degree; ++j)
		{
			stream >> child;
			if (0 == j)
			{
				node[n].left = child;
			}
			else
			{
				node[left].right = child;
			}
			left = child;
			node[child].parent = n;
		}
	}

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

	Depth(r, 0);

	for (int i = 0; i < num; ++i)
	{
		Print(i);
	}
	
}



Measured memory_bytes: 7852