using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;

namespace BinaryTree
{
    internal class Program
    {
        public const int nil = -1;
        public static Node[] tree;
        
        public static void Main(string[] args)
        {
            
            var n = int.Parse(ReadLine());
            tree = new Node[n];
            for (var i = 0; i < n; i++)
            {
                tree[i] = new Node();
            }

            for (var i = 0; i < n; i++)
            {
                var input = ReadLine().Split(' ').Select(int.Parse).ToList();
                tree[input[0]].id = input[0];
                tree[input[0]].left = input[1];
                tree[input[0]].right = input[2];
                
                if (input[1] != nil) tree[input[1]].Parent = input[0];
                if (input[2] != nil) tree[input[2]].Parent = input[0];
            }

          var sw = new StreamWriter(OpenStandardOutput()) {AutoFlush = false};
          SetOut(sw);
          for(var i = 0; i < n; i++) Print(i);
          Out.Flush();
        }

        public class Node
        {
            public int id;
            public int left, right, depth;
            private int parent;

            public Node()
            {
                parent = nil;
            }

            public int Parent
            {
                get
                {
                    if (tree[id].parent == nil) return nil;
                    else return parent;
                }
                set { this.parent = value; }
            }

            public int Sibling
            {
                get
                {
                    if (this.parent == -1) return -1; // rootの場合
                    if (tree[parent].left != this.id && tree[parent].left != -1) return tree[parent].left;
                    if (tree[parent].right != this.id && tree[parent].right != -1) return tree[parent].right;
                    return -1;
                }
            }

            public int Degree
            {
                get
                {
                    var value = 0;
                    if (left != nil) value++;
                    if (right != nil) value++;
                    return value;
                }
            }

            public int Depth
            {
                get
                {
                    depth = 0;
                    var tmp = id;
                    // SetDepth(id);
                    while (true)
                    {
                        if (tree[tmp].parent == nil) break;
                        tmp = tree[tmp].parent;
                        depth++;
                    }
                    return depth;
                }
            }

            // public int Height => SetHeight(id);
            public int Height
            {
                get
                {
                    return SetHeight(id);
                }
            }
            public string Type
            {
                get
                {
                    if (tree[id].parent == nil) return "root";
                    if (Height == 0) return "leaf";
                    return "internal node";
                }
            }

            private void SetDepth(int id)
            {
                depth++;
                if (tree[id].parent == nil) return;
                SetDepth(tree[id].parent);
            }

            private int SetHeight(int id)
            {
                var h1 = 0;
                var h2 = 0;
               if (tree[id].left != nil) h1 = SetHeight(tree[id].left) + 1;
               if (tree[id].right != nil) h2 = SetHeight(tree[id].right) + 1;
//                while (tree[id].left != nil)
//                {
//                    h1++;
//                    id = tree[id].left;
//                }
//                while (tree[id].right != nil)
//                {
//                    h2++;
//                    id = tree[id].right;
//                }

                return h1 > h2 ? h1 : h2;

            }
        }

        private static void Print(int i)
        {
                Write("node " + tree[i].id + ": ");
                Write("parent = " + tree[i].Parent + ", ");
                Write("sibling = " + tree[i].Sibling + ", ");
                Write("degree = " + tree[i].Degree + ", ");
                Write("depth = " + tree[i].Depth + ", ");
                Write("height = " + tree[i].Height + ", ");
                WriteLine(tree[i].Type);
        }
        
    }


}



Measured memory_bytes: 18340