object Main extends App {
  val children = collection.mutable.Map.empty[String, Array[String]]
  val parent = collection.mutable.Map.empty[String, String]
  val n = io.StdIn.readInt()

  for {
    _ <- 0 until n
    l = io.StdIn.readLine()split(" ", 3)
  } l match {
    case Array(id, _) => children.put(id, Array.empty[String])
    case Array(id, _, nodes) =>
      val nodeSeq = nodes.split(" ")
      children.put(id, nodeSeq)
      nodeSeq foreach(parent.put(_, id))
  }

  for (i <- 0 until n) {
    val current = i.toString
    val p = parent.get(current) match {
      case None => "-1"
      case Some(x) => x
    }
    def depth(s: String): Int = parent.get(s) match {
      case None => 0
      case Some(x) => 1 + depth(x)
    }
    val d = depth(current)
    val c = children(current).mkString("[", ", ", "]")

    val t = if (p == "-1") "root" else if (c == "[]") "leaf" else "internal node"

    println(s"node $i: parent = $p, depth = $d, $t, $c")
  }
}