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

namespace ALDS1_7_B {
    class Node {
        public int Left { get; set; }
        public int Right { get; set; }
        public int Parent { get; set; }
        public int Sibling { get; set; }
        public int Degree { get; set; }
        public int Depth { get; set; }
        public int Height { get; set; }

        public Node() {
            Left = Right = -1;
            Parent = Sibling = -1;
        }
    }

    class Problem {
        private int _n, _root;
        private Dictionary<int, Node> _nodes;

        public Problem(int n) {
            _n = n;
            _nodes = Enumerable.Range(0, n).ToDictionary(i => i, i => new Node());
        }

        public void Run() {
            SetNodes();
            _root = SearchRoot();
            SetDepth(_root, 0);
            SetHeight(_root);
            Print();
        }

        private void SetNodes() {
            for (int i = 0; i < _n; i++) {
                string[] input = Console.ReadLine().Split(' ');
                int id = int.Parse(input[0]);
                int left = int.Parse(input[1]);
                int right = int.Parse(input[2]);

                if (left != -1) {
                    _nodes[left].Parent = id;
                    _nodes[id].Left = left;
                    _nodes[id].Degree++;
                }
                if (right != -1) {
                    _nodes[right].Parent = id;
                    _nodes[id].Right = right;
                    _nodes[id].Degree++;
                }
                if (left != -1 && right != -1) {
                    _nodes[left].Sibling = right;
                    _nodes[right].Sibling = left;
                }
            }
        }

        private int SearchRoot() {
            for(int i = 0; i < _n; i++) {
                if (_nodes[i].Parent == -1)
                    return i;
            }
            return -1;
        }

        private void SetDepth(int id,int depth) {
            if (id == -1)
                return;
            _nodes[id].Depth = depth;
            SetDepth(_nodes[id].Left, depth + 1);
            SetDepth(_nodes[id].Right, depth + 1);
        }

        private int SetHeight(int id) {
            int heightL = 0, heightR = 0;
            if (_nodes[id].Left != -1)
                heightL = SetHeight(_nodes[id].Left) + 1;
            if (_nodes[id].Right != -1)
                heightR = SetHeight(_nodes[id].Right) + 1;
            return _nodes[id].Height = Math.Max(heightL, heightR);
        }

        private void Print() {
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < _n; i++) {
                sb.Append("node " + i);
                sb.Append(": parent = " + _nodes[i].Parent);
                sb.Append(", sibling = " + _nodes[i].Sibling);
                sb.Append(", degree = " + _nodes[i].Degree);
                sb.Append(", depth = " + _nodes[i].Depth);
                sb.Append(", height = " + _nodes[i].Height);
                sb.AppendLine(", " + GetType(i));
            }
            Console.Write(sb);
        }

        private string GetType(int id) {
            if (_nodes[id].Parent == -1)
                return "root";
            if (_nodes[id].Degree == 0)
                return "leaf";
            return "internal node";
        }
    }

    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            Problem pb = new Problem(n);
            pb.Run();
        }
    }
}

Measured memory_bytes: 9948