import scala.io.StdIn.{readInt, readLine}
case class Printable[T](value: T, parent: T, depth: Int, children: List[T]) {
    override def toString(): String = {
        val nodeType = if (depth == 0) "root" else if (children == Nil) "leaf" else "internal node"
        val c = children.mkString(", ")
        s"node ${value}: parent = ${parent}, depth = ${depth}, ${nodeType}, [${c}]"
    }
}
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(curr: Int, children: List[Int], parent: Int, depth: Int): Unit = {
            val nodeType = if (parent == -1) "root" else if (tree(curr) == Nil) "leaf" else "internal node"
            val c = tree(curr).mkString(", ")
            ret(curr) = s"node ${curr}: parent = ${parent}, depth = ${depth}, ${nodeType}, [${c}]"
            children match {
                case Nil => Unit
                case x :: xs => {
                    go(x, tree(x), curr, depth + 1)
                    go(curr, xs, parent, depth)
                }
            }
        }
        go(root, tree(root), -1, 0)
        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"))
    }
}
