using System;
using System.Text;

namespace ALDS1_7_B
{
    public struct node
    {
        public int parent;
        public int left;
        public int right;

        public node(int parent, int left, int right)
        {
            this.parent = parent;
            this.left = left;
            this.right = right;
        }
    }

    class Program
    {
        public static int nil = -1;

        static int[] S = new int[25];
        static int[] de = new int[25];

        static int getdepth(int u, node[] T)
        {
            int d = 0;
            while (T[u].parent != nil)
            {
                u = T[u].parent;
                d++;
            }
            return d;
        }

        static int[] D = new int[25];

        static void setdepth(int u, int p, node[] T)
        {
            D[u] = p;
            if (T[u].right != nil)
            {
                setdepth(T[u].right, p+1, T);
            }
            if (T[u].left != nil)
            {
                setdepth(T[u].left, p + 1, T);
            }
        }

        static int[] H = new int[25];

        static int setheight(int u,node[] T)
        {
            int h1 = 0;
            int h2 = 0;
            if (T[u].left != nil)
            {
                h1 = setheight(T[u].left, T) + 1;
            }
            if (T[u].right != nil)
            {
                h2 = setheight(T[u].right, T) + 1;
            }
            H[u] = Math.Max(h1, h2);
            return H[u];
        }

        static StringBuilder sbchildren(int u, node[] T)
        {
            var sb = new StringBuilder();
            sb.Append(" [");
            int c = T[u].left;

            while (c != nil)
            {
                sb.Append(c + ", ");
                c = T[c].right;
            }

            sb.Remove(sb.Length - 2, 2);

            return sb;
        }

        static int rootchecker(node[] T)
        {
            for (int i = 0; i < T.Length; i++)
            {
                if (T[i].parent == nil)
                {
                    return i;
                }
            }
            return 0;
        }

        static void tstart(node[] T,int n)
        {
            for (int i = 0; i < n; i++)
            {
                T[i].parent = nil;
                T[i].left = nil;
                T[i].right = nil;
                S[i] = nil;
            }
            for (int i = 0; i < n; i++)
            {
                var input = getsplit();
                int[] a = Array.ConvertAll(input, int.Parse);
                int count = 0;
                if (a[1] != -1)
                {
                    T[a[0]].left = a[1];
                    T[a[1]].parent = a[0];
                    count++;
                    if (a[2]!= -1)
                    {
                        S[a[1]] = a[2];
                    }
                }
                if (a[2] != -1)
                {
                    T[a[0]].right = a[2];
                    T[a[2]].parent = a[0];
                    count++;
                    if (a[1] != -1)
                    {
                        S[a[2]] = a[1];
                    }
                }
                de[a[0]] = count;

            }
        }

        static void Main(string[] args)
        {
            int n = getint();
            node[] T = new node[n];
            tstart(T, n);

            int r = rootchecker(T);
            setdepth(r, 0, T);
            setheight(r, T);

            for (int i = 0; i < n; i++)
            {
                var sb = new StringBuilder();
                sb.Append("node " + i + ": ");
                sb.Append("parent = " + T[i].parent + ", ");
                sb.Append("sibling = " + S[i] + ", ");
                sb.Append("degree = " + de[i] + ", ");
                sb.Append("depth = " + D[i] + ", ");
                sb.Append("height = " + H[i] + ", ");

                if (D[i] == 0)
                {
                    sb.Append("root");
                   
                }
                else
                {

                    if (de[i] == 0 )
                    {
                        sb.Append("leaf");
                    }
                    else
                    {
                        sb.Append("internal node");                 
                    }
                }
                Console.WriteLine(sb);
            }
        }

        public static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        public static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
    }
}

Measured memory_bytes: 9152