import scala.io.StdIn.{readInt, readLine}
case class Node[T](value: T, var children: List[Node[T]])
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() {
    var node: Node[Int] = null
    
    def add(target: Int, c: List[Int]): Unit = {
        if (node == null) {
            node = new Node[Int](target, c.map(new Node[Int](_, Nil)))
        } else search(target) match {
            case n: Node[Int] => n.children = c.map(new Node[Int](_, Nil))
            case null => {
                val c2 = c.map { e => search(e) match {
                    case null => new Node[Int](e, Nil)
                    case n => n
                    }
                }
                node = new Node[Int](target,  c2)
            }
        }
    }

    def search(target: Int): Node[Int] = {
        def go(nodes: List[Node[Int]]): Node[Int] = nodes match {
            case Nil => null
            case x :: xs if x.value == target => x
            case x :: xs => go(x.children) match {
                case null => go(xs)
                case ret => ret
            }
        }
        if (node.value == target) node else go(node.children)
    }
    
    def toPrintableList(): List[Printable[Int]] = {
        def go(nodes: List[Node[Int]], ret: List[Printable[Int]], parent: Int, depth: Int): List[Printable[Int]] = nodes match {
            case Nil => ret
            case x :: xs => {
                val ret2 = new Printable(x.value, parent, depth, x.children.map(_.value)) :: ret
                val ret3 = go(x.children, ret2, x.value, depth + 1) // 縦
                go(xs, ret3, parent, depth) // 横
            }
        }
        val init = List(new Printable(node.value, -1, 0, node.children.map(_.value)))
        go(node.children, init, node.value, 1)
    }
}
object Main {
    def main(args: Array[String]): Unit = {
        val len = readInt
        val t = new IntTree()
        val l = (0 until len).foreach { i =>
            val line = readLine.split(" ").map(_.toInt)
            val c = line.slice(2, line.length).toList
            val p = line.head
            t.add(p, c)
        }
        println(t.toPrintableList.sortBy(x => x.value).mkString("\n"))
    }
}
