import scala.io.StdIn.{readInt, readLine}
class IntTree(size: Int) {
    val tree: Array[List[Int]] = new Array[List[Int]](size)
    var root: Int = -1
    
    def add(target: Int, c: List[Int]): Unit = {
        tree(target) = c
        if (root == -1 || c.contains(root)) root = target
    }
    def toPrintableArray(): Array[String] = {
        val ret = new Array[String](size)
        def go(children: List[Int], parent: Int, depth: Int): Unit = {
            if (children != Nil) {
                val target = children.head
                val nodeType = if (tree(target) == Nil) "leaf" else "internal node"
                val c = tree(target).mkString(", ")
                ret(target) = s"node ${target}: parent = ${parent}, depth = ${depth}, ${nodeType}, [${c}]"
                go(tree(target), target, depth + 1)
                val tail = children.tail
                if (tail != Nil) go(tail, parent, depth)
            }
        }
        val c = tree(root).mkString(", ")
        ret(root) = s"node ${root}: parent = -1, depth = 0, root, [${c}]"
        go(tree(root), root, 1)
        ret
    }
}
object Main {
    def main(args: Array[String]): Unit = {
        val len = readInt
        val t = new IntTree(len)
        (0 until len).foreach { i =>
            val line = readLine.split(" ").map(_.toInt)
            t.add(line.head, line.slice(2, line.length).toList)
        }
        println(t.toPrintableArray.mkString("\n"))
    }
}
