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 BinaryNode<int>[N];
			for(int i = 0; i < N; i++) 
				Nodes[i] = new BinaryNode<int> { Id = i };
			for(int lineNo = 0; lineNo < N; lineNo++) {
				var id = cin.ReadInt;
				var l = cin.ReadInt;
				var r = cin.ReadInt;
				Nodes[id].Adopt(l == -1 ? null : Nodes[l], r == -1 ? null : Nodes[r]);
			}
			int[] Heights;
			BinaryNode<int>.GetHeight(Nodes, out Heights);
			string[] Parameters = { "parent", "sibling", "degree", "depth", "height" };
			for(int i = 0; i < N; i++) {
				var node = Nodes[i];
				int[] Values = { 
					node.isRoot ? -1 : node.Parent.Id,
					node.Sibling?.Id ?? -1,
					node.Degree,
					node.Depth,
					Heights[i]
				};
				var props = Parameters.Zip(Values, (s, v) => $"{s} = {v}").ToList();
				props.Add((node.isRoot ? "root" : node.isLeaf ? "leaf" : "internal node"));
				Console.WriteLine($"node {node.Id}: " +
					props.Join(", ")
				);
			}
		}
		class TreeNode<T> {
			public virtual TreeNode<T> Parent { get; set; }
			public T Value { get; set; }
			public int Id { get; set; }
			public virtual List<TreeNode<T>> Children { get; set; } = new List<TreeNode<T>>();
			public virtual bool isRoot { get { return Parent == null; } }
			public virtual bool isLeaf { get { return !Children.Any(); } }
			public bool isInternal { get { return !isRoot && !isLeaf; } }
			public virtual int Depth {
				get {
					var count = 0;
					var P = this;
					while(!P.isRoot) {
						P = P.Parent;
						count++;
					}
					return count;
				}
			}
			public int Height {
				get {
					if(isLeaf) return 0;
					return Children.Select(X => X.Height).Max() + 1;
				}
			}
			public virtual int Degree { get { return Children.Count(); } }
			
			public void AdoptMany(List<TreeNode<T>> children) {
				Children = children;
				foreach(var node in children)
					node.Parent = this;
			}
			public void AdoptMany(TreeNode<T>[] Base, IEnumerable<int> call) {
				var children = call.Select(k => Base[k]).ToList();
				AdoptMany(children);
			}
			public void Adopt(TreeNode<T> child) {
				Children.Add(child);
				child.Parent = this;
			}
		}
		class BinaryNode<T>: TreeNode<T> {
			public new BinaryNode<T> Parent { get; set; }
			public BinaryNode<T> Left { get; set; }
			public BinaryNode<T> Right { get; set; }
			public new List<BinaryNode<T>> Children {
				get { return new BinaryNode<T>[] { Left, Right }.Where(x => x != null).ToList(); }
			}
			public override int Depth {
				get {
					var count = 0;
					var P = this;
					while(!P.isRoot) {
						P = P.Parent;
						count++;
					}
					return count;
				}
			}
			public new bool isRoot { get { return Parent == null; } }
			public override bool isLeaf { get { return Left == null && Right == null; } }
			public override int Degree {
				get { return (Left != null ? 1 : 0) + (Right != null ? 1 : 0); }
			}
			public void Adopt(BinaryNode<T> left, BinaryNode<T> right) {
				Left = left; Right = right;
				if(left != null) left.Parent = this; if(right != null) right.Parent = this;
			}
			public BinaryNode<T> Sibling {
				get { return isRoot ? null : Equals(Parent.Left) ? Parent.Right : Parent.Left; }
			}
			public static void GetHeight(BinaryNode<T>[] Nodes, out int[] Res) {
				Res = new int[Nodes.Length];
				foreach(var root in Nodes.Where(n => n.isRoot)) {
					GetHeight(root, Res);
				}
			}
			private static void GetHeight(BinaryNode<T> now, int[] Res) {
				if(now.isLeaf || !now.Children.Any()) { Res[now.Id] = 0; return; }
				foreach(var child in now.Children) {
					GetHeight(child, Res);
				}
				Res[now.Id] = now.Children.Max(c => Res[c.Id]) + 1;
			}
		}
	}
	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: 19060