using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        public class Node
        {
            public int id;
            public int parent = -1;
            public int left = -1;
            public int right = -1;
            public int sibling= -1;
            public int height;
            public int depth;
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Node[] nodes = new Node[n];
            for(int i = 0; i < nodes.Length; ++i) { nodes[i] = new Node(); }
            for (int i = 0; i < n; ++i)
            {
                int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
               
                int id = arr[0];
                int l = arr[1];
                int r = arr[2];
                nodes[id].id = id;
                nodes[id].left = l;
                nodes[id].right = r;
                if (l != -1)
                {
                    nodes[l].parent = id;
                    nodes[l].sibling = r;
                }
                if (r != -1)
                {
                    nodes[r].parent = id;
                    nodes[r].sibling = l;
                }
            }
            Node rootnode = nodes.First(p => p.parent == -1);
            SetDepth(nodes, rootnode);
            SetHeight(nodes, rootnode);
           
            foreach(Node node in nodes)
            {
                string type = null;
                if( node.depth == 0)
                {
                    type = "root";
                }else if( node.left != -1 || node.right != -1)
                {
                    type = "internal node";
                }else
                {
                    type = "leaf";
                }
                int degree = 0;
                if( node.left != -1) { degree++; }
                if( node.right != -1) { degree++; }
                string sz = string.Format("node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}", node.id, node.parent, node.sibling, degree, node.depth, node.height, type);
                Console.WriteLine(sz);

            }
        }
        private static void SetDepth(Node[] nodes, Node parent)
        {
            if(parent.left != -1)
            {
                nodes[parent.left].depth = parent.depth + 1;
                SetDepth(nodes, nodes[parent.left]);
            }
            if(parent.right != -1)
            {
                nodes[parent.right].depth = parent.depth + 1;
                SetDepth(nodes, nodes[parent.right]);

            }
        }
        private static int SetHeight(Node[] nodes, Node parent)
        {
            int h1 = 0;
            int h2 = 0;
            if (parent.left != -1)
            {
                h1 = SetHeight(nodes, nodes[parent.left]) + 1;
            }
            if (parent.right != -1)
            {
                h2 = SetHeight(nodes, nodes[parent.right]) + 1;
            }
            int h = Math.Max(h1, h2);
            parent.height = h;
            return h;
        }
    }

}



Measured memory_bytes: 9632