<?php

if (!empty($argv[1])) {
    Util::enablingDebug();
}

myMain();

// bench
Util::printBench();

class Util
{
    private static $isDebug = false;
    private static $startTime;

    public static function input($isSplitSpace = false)
    {
        $input = trim(fgets(STDIN));
        if (!$isSplitSpace) {
            return $input;
        }

        return explode(' ', $input);
    }

    public static function arrToStr($arr, $del = " ")
    {
        return implode($del, $arr);
    }

    public static function enablingDebug()
    {
        self::$isDebug = true;
        self::$startTime = time();
    }

    public static function DebugLog($text, $isReturn = true)
    {
        if (self::$isDebug) {
            echo $text;
            if ($isReturn) {
                echo PHP_EOL;
            }
        }
    }

    public static function varDump($obj)
    {
        if (self::$isDebug) {
            var_dump($obj);
        }
    }

    public static function arrFirst($arr)
    {
        if (empty($arr) || !is_array($arr)) {
            return null;
        }

        return current($arr);
    }

    public static function arrLast($arr)
    {
        if (empty($arr) || !is_array($arr)) {
            return null;
        }

        return end($arr);
    }

    public static function printBench()
    {
        if (!self::$isDebug) {
            return;
        }

        echo sprintf("Fin. Time: %.3f s  MemoryPeakUsage: %.3f KB" . PHP_EOL, time() - self::$startTime, memory_get_peak_usage() / 1024);
    }

    public static function swapArr($arr, $a, $b)
    {
        $tmp = $arr[$a];
        $arr[$a] = $arr[$b];
        $arr[$b] = $tmp;
        return $arr;
    }
}


function myMain()
{
    // START
    $n = Util::input();

    // ノード初期化
    /** @var Node[] $nodeList */
    $nodeList = [];
    for ($i = 0; $i < $n; ++$i) {
        $nodeList[] = new Node($i);
    }

    for ($i = 0; $i < $n; ++$i) {
        $input = Util::input(true);
        $nodeIndex = $input[0];
        $k = $input[1];

        if ($k > 0) {
            $childList = [];
            foreach (array_slice($input, 2) as $childIndex) {
                // set parent
                $nodeList[$childIndex]->setParent($nodeList[$nodeIndex]);
                // set child
                $childList[] = $nodeList[$childIndex];
            }
            $nodeList[$nodeIndex]->setChild($childList);
        }
    }

    // output
    foreach ($nodeList as $node) {
        $depth = Node::getDepth($nodeList, $node);
        $txt = sprintf("node %s: parent = %s, depth = %s, ",
            $node->getNodeIndex(),
            $node->getParentIndex(),
            $depth
        );

        $childIndexList = $node->getChildIndexList();

        if ($depth == 0) {
            $txt .= "root, [" . Util::arrToStr($childIndexList, ', ') . "]";
        } else {
            if (empty($childIndexList)) {
                $txt .= "leaf, []";
            } else {
                $txt .= "internal node, [" . Util::arrToStr($childIndexList, ', ') . "]";
            }
        }

        echo $txt . PHP_EOL;
    }

}

class Node
{
    private $_nodeIndex;
    /** @var Node */
    private $_parent;
    /** @var Node[] */
    private $_childList = [];

    public function __construct($nodeIndex)
    {
        $this->_nodeIndex = $nodeIndex;
    }

    /**
     * @param Node[] $nodeList
     */
    public static function getDepth($nodeList, Node $node)
    {
        $depth = 0;
        while ($node->getParentIndex() != -1) {
            $depth += 1;
            $node = $nodeList[$node->getParentIndex()];
        }

        return $depth;
    }

    public function getNodeIndex()
    {
        return $this->_nodeIndex;
    }

    public function getParentIndex()
    {
        if (empty($this->_parent)) {
            return -1;
        }

        return $this->_parent->getNodeIndex();
    }

    public function getChildIndexList()
    {
        return array_map(function (Node $v) {
            return $v->getNodeIndex();
        }, $this->_childList);
    }

    public function setChild($childList)
    {
        $this->_childList = $childList;
        return $this;
    }

    public function setParent(Node $parent)
    {
        $this->_parent = $parent;
        return $this;
    }
}



Measured memory_bytes: 82316