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

namespace B
{
    public struct Node
    {
        public int parent;
        public int child;
        public int sibling;
        public int depth;
        public int height;
        public Tree tree;

        public string Type
        {
            get
            {
                if (parent == -1) return "root";
                else if (child == -1) return "leaf";
                else return "internal node";
            }
        }

        public int[] Children
        {
            get
            {
                var list = new List<int>();
                if (child != -1)
                {
                    list.Add(child);
                    if (tree.nodes[child].sibling != -1) list.Add(tree.nodes[child].sibling);
                }
                return list.ToArray();
            }
        }

        public void SetHeight(int height)
        {
            if (this.height < height) this.height = height;
            if (parent != -1) tree.nodes[parent].SetHeight(height + 1);
        }

        public void SetDepth(int depth)
        {
            this.depth = depth;
            foreach (var child in Children) tree.nodes[child].SetDepth(depth + 1);
        }
    }

    public class Tree
    {
        internal Node[] nodes;

        public Tree(int nodes)
        {
            this.nodes = new Node[nodes];
            for (int i = 0; i < nodes; i++)
            {
                this.nodes[i].depth = 0;
                this.nodes[i].height = 0;
                this.nodes[i].parent = -1;
                this.nodes[i].child = -1;
                this.nodes[i].sibling = -1;
                this.nodes[i].tree = this;
            }
        }

        public void AddChilden(int id, params int[] children)
        {
            if (children.Length > 0) nodes[id].child = children[0];
            int last = -1;
            foreach (var node in children)
            {
                nodes[node].parent = id;
                nodes[node].SetDepth(nodes[id].depth + 1);
                if (last != -1)
                {
                    nodes[last].sibling = node;
                    nodes[node].sibling = last;
                }
                last = node;
                if (nodes[id].height < nodes[node].height + 1) nodes[id].SetHeight(nodes[node].height + 1);
            }
        }

        public Node At(int i)
        {
            return nodes[i];
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var tree = new Tree(n);
            for (int i = 0; i < n; i++)
            {
                var strs = Console.ReadLine().Split(' ');
                var id = int.Parse(strs[0]);
                tree.AddChilden(id, Array.ConvertAll(strs.Skip(1).Where(s => !s.Equals("-1")).ToArray(), int.Parse));
            }
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine("node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}",
                                  i,
                                  tree.At(i).parent,
                                  tree.At(i).sibling,
                                  tree.At(i).Children.Length,
                                  tree.At(i).depth,
                                  tree.At(i).height,
                                  tree.At(i).Type
                                 );

            }
        }
    }
}

Measured memory_bytes: 9608