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

namespace _20170410_AOJ
{
    class ALDS1_7A
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if(string.IsNullOrEmpty(line))
                {
                    break;
                }

                int n = int.Parse(line);

                TreeNode[] arr = new TreeNode[n];
                for (int i = 0; i < n; i++)
                {
                    int[] nInfo = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

                    int id = nInfo[0];
                    int k = nInfo[1];
                    TreeNode tn = arr[id];
                    if (tn == null)
                    {
                        tn = new TreeNode();
                        tn.Id = id;
                        arr[tn.Id] = tn;
                    }

                    for (int j = 2; j < k + 2; j++)
                    {
                        int cId = nInfo[j];
                        TreeNode cn = arr[cId];
                        if (cn == null)
                        {
                            cn = new TreeNode();
                            cn.Id = cId;
                            arr[cId] = cn;
                        }
                        tn.Children.Add(cn);
                        cn.Parent = tn;
                    }
                }

                TreeNode root = arr[0].GetRoot();
                root.SetDepthRecursive(0);

                foreach (var v in arr)
                {
                    WriteTreeNode(v);
                }
            }
        }

        static void WriteTreeNode(TreeNode tn)
        {
            int parent = (tn.Parent == null) ? -1 : tn.Parent.Id;
            Console.Write("node {0}: parent = {1}, depth = {2}, ", tn.Id, parent, tn.Depth);
            if (parent < 0)
            {
                Console.Write("root, [");
            }
            else
            {
                if (tn.Children.Count > 0)
                {
                    Console.Write("internal node, [");
                }
                else
                {
                    Console.Write("leaf, [");
                }
            }

            Console.Write(string.Join(", ", tn.Children.Select(x => x.Id.ToString()).ToArray()));
            Console.WriteLine("]");
        }
    }

    class TreeNode
    {
        public int Id { get; set; }
        public List<TreeNode> Children { get; set; }
        public TreeNode Parent { get; set; }
        public int Depth { get; internal set; }
        public TreeNode()
        {
            Children = new List<TreeNode>();
        }

        public void SetDepth()
        {
            int d = 0;
            TreeNode temp = this;
            do
            {
                temp = temp.Parent;
                d++;
            } while (temp != null);

            Depth = d;
        }

        public TreeNode GetRoot()
        {
            TreeNode temp = this;
            while(temp.Parent != null)
            {
                temp = temp.Parent;
            }

            return temp;
        }

        public void SetDepthRecursive(int depth)
        {
            Depth = depth;
            foreach(var v in Children)
            {
                v.SetDepthRecursive(Depth + 1);
            }
        }
    }
}



Measured memory_bytes: 27856