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

namespace ALDS1_7_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Node[] nodeAry = new Node[n];

            for (int i = 0; i < n; i++)
            {
                nodeAry[i] = new Node();
            }

            for (int i = 0; i < n; i++)
            {
                int[] tmpLine = Console.ReadLine()
                                          .Split(' ')
                                          .Select(s => int.Parse(s))
                                          .ToArray();
                //左子
                if (tmpLine.Length > 2)
                {
                    nodeAry[tmpLine[0]].leftSon = tmpLine[2];
                }

                //右兄弟
                if (tmpLine.Length > 3)
                {
                    for (int j = 2; j < tmpLine.Length - 1; j++)
                    {
                        nodeAry[tmpLine[j]].rightBr = tmpLine[j + 1];
                    }
                }

                //親
                if (tmpLine.Length > 2)
                {
                    for (int j = 2; j < tmpLine.Length; j++)
                    {
                        nodeAry[tmpLine[j]].parent = tmpLine[0];
                    }
                }
            }

            for (int i = 0; i < n; i++)
            {
                if (nodeAry[i].parent == -1)
                {
                    Node.SetDepth(nodeAry, nodeAry[i], -1);
                    break;
                }
            }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine("node {0}: parent = {1}, depth = {2}, {3}, [{4}]", i, nodeAry[i].parent, nodeAry[i].depth, nodeAry[i].type, string.Join(", ", nodeAry[i].GetSons(nodeAry)));
            }
            //Console.ReadLine();
        }
    }

    class Node
    {
        public int parent = -1;
        public int leftSon = -1;
        public int rightBr = -1;
        public int depth = -1;
        public string type
        {
            get {
                if (this.parent == -1)
                {
                    return "root";
                }
                else if (this.leftSon == -1)
                {
                    return "leaf";
                }
                else
                {
                    return "internal node";
                }
            }
        }

        public static void SetDepth(Node[] nodeAry, Node node, int parentDepth)
        {
            node.depth = parentDepth + 1;

            if (node.rightBr >= 0)
            {
                Node.SetDepth(nodeAry, nodeAry[node.rightBr], parentDepth);
            }

            if (node.leftSon >= 0)
            {
                Node.SetDepth(nodeAry, nodeAry[node.leftSon], node.depth);
            }
        }

        public List<int> GetSons(Node[] nodeAry)
        {
            List<int> sonList = new List<int>();

            int tmpIndx = this.leftSon;
            while (tmpIndx >= 0)
            {
                sonList.Add(tmpIndx);
                tmpIndx = nodeAry[tmpIndx].rightBr;
            }

            return sonList;
        }
    }
}



Measured memory_bytes: 38924