using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var Nodes = new TreeNode<int>[N];
			for(int i = 0; i < N; i++) 
				Nodes[i] = new TreeNode<int> { Value = i };
			for(int lineNo = 0; lineNo < N; lineNo++) {
				var id = cin.ReadInt;
				var k = cin.ReadInt;
				if(k == 0) continue;
				var children = cin.ReadIntArray(k);
				Nodes[id].Adopt(Nodes, children);
			}
			for(int i = 0; i < N; i++) {
				var node = Nodes[i];
				Console.WriteLine($"node {node.Value}: " +
				$"parent = {(node.isRoot ? -1 : node.Parent.Value)}, " +
				$"depth = {node.Depth}, " +
				$"{(node.isRoot ? "root" : node.isLeaf ? "leaf" : "internal node")}, " +
				$"[{node.Children.Select(C => C.Value).Join(", ")}]"
				);
			}
		}
		class TreeNode<T> {
			public TreeNode<T> Parent { get; set; }
			public T Value { get; set; }
			public List<TreeNode<T>> Children { get; set; } = new List<TreeNode<T>>();
			public bool isRoot { get { return Parent == null; } }
			public bool isLeaf { get { return !Children.Any(); } }
			public bool isInternal { get { return !isRoot && !isLeaf; } }
			public int Depth {
				get {
					var count = 0;
					var P = this;
					while(!P.isRoot) {
						P = P.Parent;
						count++;
					}
					return count;
				}
			}
			public void Adopt(List<TreeNode<T>> children) {
				Children = children;
				foreach(var node in children)
					node.Parent = this;
			}
			public void Adopt(TreeNode<T>[] Base, IEnumerable<int> call) {
				var children = call.Select(k=>Base[k]).ToList();
				Adopt(children);
			}
			public void AddChild(TreeNode<T> child) {
				Children.Add(child);
				child.Parent = this;
			}
		}
	}
	static class ExtendClass {
		public static void Swap<T>(this T[] A, int x, int y) {
			var tmp = A[x];
			A[x] = A[y];
			A[y] = tmp;
		}
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		//http://baba-s.hatenablog.com/entry/2017/12/21/104600
		public static IEnumerable<IEnumerable<T>> Chunks<T>(this IEnumerable<T> self, int size) {
			while(self.Any()) {
				yield return self.Take(size);
				self = self.Skip(size);
			}
		}
		public static IEnumerable<T> MinBy<T, U>(this IEnumerable<T> source, Func<T, U> selector) {
			return SelectBy(source, selector, (a, b) => Comparer<U>.Default.Compare(a, b) < 0);
		}

		public static IEnumerable<T> MaxBy<T, U>(this IEnumerable<T> source, Func<T, U> selector) {
			return SelectBy(source, selector, (a, b) => Comparer<U>.Default.Compare(a, b) > 0);
		}

		private static IEnumerable<T> SelectBy<T, U>(IEnumerable<T> source, Func<T, U> selector, Func<U, U, bool> comparer) {
			var list = new LinkedList<T>();
			U prevKey = default(U);
			foreach(var item in source) {
				var key = selector(item);
				if(list.Count == 0 || comparer(key, prevKey)) {
					list.Clear();
					list.AddLast(item);
					prevKey = key;
				} else if(Comparer<U>.Default.Compare(key, prevKey) == 0) {
					list.AddLast(item);
				}
			}
			return list;
		}
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}

}



Measured memory_bytes: 44032