data class Node(var parentNodeNum: Int = -1, var depth: Int = 0, var nodeType: NodeType = NodeType.ROOT, val childMap: MutableMap<Int, Node> = mutableMapOf())
enum class NodeType {
    ROOT {
        override fun toString() = "root"
    },
    INTERNAL_NODE {
        override fun toString() = "internal node"
    },
    LEAF {
        override fun toString() = "leaf"
    }
}

fun main(args: Array<String>) {
    val inputList = List(readLine()?.toInt() ?: return) {
        readLine()?.split(" ".toRegex())?.map(String::toInt) ?: listOf()
    }
    val nodeMap = mutableMapOf<Int, Node>()
    inputList.forEach { input ->
        val nodeNum = input[0]
        nodeMap.putIfAbsent(nodeNum, Node())
        nodeMap[nodeNum]?.let { parentNode ->
            input.subList(2, input.size).forEach { childNum ->
                nodeMap.putIfAbsent(childNum, Node())
                nodeMap[childNum]?.let { childNode ->
                    childNode.parentNodeNum = nodeNum
                    parentNode.childMap[childNum] = childNode
                }
            }
        }
    }
    nodeMap.values.find { it.parentNodeNum == -1 }?.let { rootNode ->
        recDepth(rootNode, 0)
    }
    val stringBuilder = StringBuilder()
    for (i in inputList.indices) {
        nodeMap[i]?.let { node ->
            stringBuilder.append("node $i: parent = ${node.parentNodeNum}, depth = ${node.depth}, ${node.nodeType}, ${node.childMap.keys}\n")
        }
    }
    print(stringBuilder.toString())
}

fun recDepth(node: Node, depth: Int) {
    node.depth = depth
    when {
        node.parentNodeNum == -1 -> node.nodeType = NodeType.ROOT
        node.childMap.isEmpty() -> node.nodeType = NodeType.LEAF
        else -> node.nodeType = NodeType.INTERNAL_NODE
    }
    node.takeIf { it.childMap.isNotEmpty() }?.childMap?.forEach { _, child ->
        recDepth(child, depth + 1)
    }
}
