using System;
using System.Linq;

namespace ALDS1_7_A_RootedTrees
{
	class Program
	{
		static void Main ( string[] args )
		{
			int dataCount = int.Parse (Console.ReadLine ());
			Tree tree = new Tree (dataCount);

			for (int lp = 0; lp < dataCount; lp++)
			{
				int[] inputNum = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
				int nodeID = inputNum[0];
				int nodeCount = inputNum[1];

				int left = 0;
				for (int lp2 = 0; lp2 < nodeCount; lp2++)
				{
					int c = inputNum[2 + lp2];

					if (lp2 == 0)
					{
						int leftNode = c;
						tree.SetLeft (nodeID, leftNode);
					}
					else
					{
						int rightNode = c;
						tree.SetRight (left, rightNode);
					}

					left = c;
					tree.SetParent (c, nodeID);
				}
			}

			int root = tree.GetParent ();

			tree.GetDepth (root, 0);

			for (int lp = 0; lp < dataCount; lp++)
			{
				tree.PrintNode (lp);
			}

		}
	}

	class Node
	{
		public int Parent { set; get; }
		public int Left { set; get; }
		public int Right { set; get; }
	}

	class Tree
	{
		public Tree ( int capacity )
		{
			this.NodeArray = new Node[capacity];
			for (int lp = 0; lp < NodeArray.Length; lp++)
			{
				this.NodeArray[lp] = new Node ();
				NodeArray[lp].Parent = NodeArray[lp].Left = NodeArray[lp].Right = Null;
			}

			this.DepthArray = new int[capacity];
		}

		private Node[] NodeArray { set; get; }
		private int[] DepthArray { set; get; }
		private const int Null = -1;

		public void SetLeft ( int nodeNumber, int leftNumber )
		{
			NodeArray[nodeNumber].Left = leftNumber;
		}
		public void SetRight ( int nodeNumber, int rightNumber )
		{
			NodeArray[nodeNumber].Right = rightNumber;
		}
		public void SetParent ( int nodeNumber, int parentNumber )
		{
			NodeArray[nodeNumber].Parent = parentNumber;
		}

		public int GetParent ()
		{
			int index = 0;

			while (NodeArray[index].Parent != Null)
			{
				index++;
			}
			return index;
		}

		public int GetDepth ( int nodeNumber )
		{
			int count = 0;

			while (NodeArray[nodeNumber].Parent != Null)
			{
				nodeNumber = NodeArray[nodeNumber].Parent;
				count++;
			}

			return count;
		}

		//???????????¨????????????????????±???????±???????
		public int[] GetDepth ( int nodeNumber, int depth )
		{
			DepthArray[nodeNumber] = depth;

			if (NodeArray[nodeNumber].Right != Null)
			{
				GetDepth (NodeArray[nodeNumber].Right, depth);
			}
			if (NodeArray[nodeNumber].Left != Null)
			{
				GetDepth (NodeArray[nodeNumber].Left, depth + 1);
			}

			return DepthArray;
		}

		public void PrintNode ( int nodeNumber )
		{
			System.Text.StringBuilder output = new System.Text.StringBuilder (150);

			output.Append ("node " + nodeNumber + ": ");
			output.Append ("parent = " + NodeArray[nodeNumber].Parent + ", ");
			output.Append ("depth = " + DepthArray[nodeNumber] + ", ");

			if (NodeArray[nodeNumber].Parent == Null)
			{
				output.Append ("root, ");
			}
			else if (NodeArray[nodeNumber].Left == Null)
			{
				output.Append ("leaf, ");
			}
			else
			{
				output.Append ("internal node, ");
			}

			output.Append ("[");

			for (int lp = 0, node = NodeArray[nodeNumber].Left; node != Null; lp++, node = NodeArray[node].Right)
			{
				if (lp != 0)
					output.Append (", ");

				output.Append (node);
			}

			output.Append ("]");
			Console.WriteLine (output);
		}
	}
}

Measured memory_bytes: 26164