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

class Program
{

    public void Proc()
    {
        int nodeCount = int.Parse(Console.ReadLine());
        Dictionary<int, TreeNd> dic = new Dictionary<int, TreeNd>();
        List<TreeNd> list = new List<TreeNd>();
        for (int i = 0; i < nodeCount; i++)
        {
            string[] inpt = Console.ReadLine().Split(' ');
            int id = int.Parse(inpt[0]);

            TreeNd newItem;
            if (dic.ContainsKey(id))
            {
                newItem = dic[id];
            }
            else
            {
                newItem = new TreeNd(id);
                dic.Add(id, newItem);
                list.Add(newItem);
            }

            for(int j=0; j<=1; j++) {
                int subId = int.Parse(inpt[1 + j]);
                if (subId >= 0)
                {
                    TreeNd subNd;
                    if (dic.ContainsKey(subId))
                    {
                        subNd = dic[subId];
                    }
                    else
                    {
                        subNd = new TreeNd(subId);
                        dic.Add(subId, subNd);
                        list.Add(subNd);
                    }
                    subNd.Parent = newItem;
                    newItem.SubTree.Add(subNd);
                }
            }
        }
        list.Sort((a, b) => {
            int dir = 1;
            if (a.NodeId == b.NodeId)
            {
                return 0;
            }
            else if (a.NodeId < b.NodeId)
            {
                return dir * -1;
            }
            else
            {
                return dir;
            }
        });
        foreach (TreeNd item in list)
        {
            Console.WriteLine(item.ToString());
        }
    }

    public class TreeNd
    {
        public int NodeId = -1;
        public TreeNd Parent = null;
        public List<TreeNd> SubTree = new List<TreeNd>();

        public TreeNd(int id)
        {
            this.NodeId = id;
        }
        public string GetNodeType()
        {
            if (this.Parent == null)
            {
                return "root";
            }
            else if (SubTree.Count <= 0)
            {
                return "leaf";
            }
            else
            {
                return "internal node";
            }
        }

        private Nullable<int> DepthValue = null;
        public int Depth
        {
            get
            {
                if (this.DepthValue != null)
                {
                    return this.DepthValue.Value;
                }
                if (this.Parent == null)
                {
                    this.DepthValue = 0;
                }
                else
                {
                    this.DepthValue = this.Parent.Depth + 1;
                }
                return this.DepthValue.Value;
            }
        }
        private TreeNd GetSibling()
        {
            if (this.Parent == null)
            {
                return null;
            }
            else if(this.Parent.SubTree.Count <= 1)
            {
                return null;
            }
            else if(this.Parent.SubTree[0] != this)
            {
                return this.Parent.SubTree[0];
            }
            else if(this.Parent.SubTree[1] != this)
            {
                return this.Parent.SubTree[1];
            }
            return null;
        }
        private int GetSiblingId()
        {
            TreeNd sib = this.GetSibling();
            if (sib == null)
            {
                return -1;
            }
            else
            {
                return sib.NodeId;
            }
        }
        private Nullable<int> HeightValue = null;
        public int Height
        {
            get
            {
                if (this.HeightValue != null)
                {
                    return this.HeightValue.Value;
                }
                int ans = 0;
                for (int i = 0; i < this.SubTree.Count; i++)
                {
                    ans = Math.Max(ans, this.SubTree[i].Height + 1);
                }
                this.HeightValue = ans;
                return ans;
            }
        }
        public override string ToString()
        {
            //node 0: parent = -1, depth = 0, root, [1, 4, 10]
            //node 1: parent = 0, depth = 1, internal node, [2, 3]
            //node 2: parent = 1, depth = 2, leaf, []
            string ret = "node " + this.NodeId + ": parent = " + ((this.Parent == null) ? -1 : this.Parent.NodeId) + ", sibling = " + this.GetSiblingId() + ", degree = " + this.SubTree.Count + ", depth = " + this.Depth + ", height = " + this.Height + ", " + this.GetNodeType();
            return ret;
        }
    }

    static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 9832