using System;
using System.Collections.Generic;
namespace alds17a
{
    class node{
        public int id;
        public node parent;
        public node left;
        public node right;
        public node sib;
        public int dep;
        public int deg;
        public int h;

        public node(int setid)
        {
            id = setid;
            deg = 0;
            h = 0;
        }
        public void seth()
        {
            if (right != null)
            {
                right.seth();
                h = right.h + 1;
            }
            if (left != null)
            {
                left.seth();
                if (h <= left.h) h = left.h + 1;
            }
        }
        public void setleft(node tgt){
            left = tgt;
            tgt.parent = this;
            tgt.setdep();
            deg++;
            if (right != null)
            {
                tgt.sib = right;
                right.sib = tgt;
            }
        }
        public void setright(node tgt)
        {
            right = tgt;
            tgt.parent=this;
            tgt.setdep();
            deg++;
            if (left != null)
            {
                tgt.sib = left;
                left.sib = tgt;
            }
        }
        public void setdep()
        {
            if (parent == null)
            {
                dep = 0;
            }
            else
            {
                dep = parent.dep + 1;
            }
            if (right != null)
            {
                right.setdep();
            }
            if (left != null)
            {
                left.setdep();
            }
            return;
        }
        string nodetype()
        {
            if (dep == 0)
            {
                return "root";
            }
            else if (deg == 0)
            {
                return "leaf";
            }
            else
            {
                return "internal node";
            }
        }
        int getid(node tgt)
        {
            if (tgt == null)
            {
                return -1;
            }
            else
            {
                return tgt.id;
            }
        }
        public void write()
        {
            Console.Write("node ");
            Console.Write(id);
            Console.Write(": parent = ");
            Console.Write(getid(parent));
            Console.Write(", sibling = ");
            Console.Write(getid(sib));
            Console.Write(", degree = ");
            Console.Write(deg);
            Console.Write(", depth = ");
            Console.Write(dep);
            Console.Write(", height = ");
            Console.Write(h);
            Console.Write(", ");
            Console.WriteLine(nodetype());
        }
    }
    class main
    {
        static void Main()
        {
            List<node> all=new List<node>();
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                all.Add(new node(i));
            }
            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int tgt = int.Parse(input[0]);
                int left = int.Parse(input[1]);
                int right = int.Parse(input[2]);
                if (left != -1) all[tgt].setleft(all[left]);
                if (right != -1) all[tgt].setright(all[right]);
            }
            foreach (node tgt in all)
            {
                if (tgt.dep == 0)
                {
                    tgt.seth();
                    break;
                }
            }
            foreach (node tgt in all)
            {
                tgt.write();
            }
        }
    }
}

Measured memory_bytes: 5684