import scala.io.StdIn.{ readLine, readInt };
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val l = (0 until n).map{ a => 
            readLine.split(" ") match {
                case Array(v, l, r) => Some((v.toInt, l.toInt, r.toInt));
                case _ => None;
            }
        }.toList
        val bTree = new BinaryTrees(n);
        bTree.build(l);
        bTree.dump();
    }
}
class BinaryTrees(len: Int) {
    case class Node(left: Int, right: Int)
    var root = -1;
    val tree = new Array[Node](len);
    def build(data: List[Option[(Int, Int, Int)]]): Unit = data match {
        case Some((value, left, right)) :: xs =>
            tree(value) = Node(left, right);
            if (root == -1 || left == root || right == root) root = value;
            build(xs);
        case x :: xs => build(xs);
        case Nil => ()
    }
    def dump(): Unit = {
        val dumpArr = new Array[String](len);
        def _dump(curr: Int, parent: Int, sibling: Int, depth: Int): Unit = {
            if (curr == -1) {
                //  nop
            } else {
                val degree = getDegree(curr);
                val nodeType = getNodeType(curr, parent);
                val height = getHeight(curr);
                dumpArr(curr) = nodeToString(curr, parent, sibling, degree, depth, height, nodeType);
                _dump(tree(curr).left, curr, tree(curr).right, depth + 1);
                _dump(tree(curr).right, curr, tree(curr).left, depth + 1);
            }
        }
        _dump(root, -1, -1, 0);
        println(dumpArr.mkString("\n"));
    }
    def getHeight(curr: Int): Int = {
        if (curr == -1) {
            -1;
        } else {
            val leftHeight = getHeight(tree(curr).left);
            val rightHeight = getHeight(tree(curr).right);
            if (leftHeight < rightHeight) rightHeight + 1 else leftHeight + 1;
        }
    }
    def nodeToString(curr: Int, parent: Int, sibling: Int, degree: Int, depth: Int, height: Int, nodeType: String): String = {
        s"node ${curr}: parent = ${parent}, sibling = ${sibling}, degree = ${degree}, depth = ${depth}, height = ${height}, ${nodeType}";
    }
    def getDegree(v: Int): Int = {
        val n = tree(v);
        var ret = 2;
        if (n.left == -1) ret -= 1;
        if (n.right == -1) ret -= 1;
        ret;
    }
    def getNodeType(v: Int, parent: Int): String = {
        if (parent == -1) "root" else if (tree(v).left == -1 && tree(v).right == -1) "leaf" else "internal node";
    }
}
