import scala.io.{StdIn, Source}

class Node {
  var id = 0
  var parent: Node    = null
  var leftChild: Node = null
  var rightSib: Node  = null

  def depth(): Int = parent match {
    case null => 0
    case _    => 1 + parent.depth
  }

  def parentId() = parent match {
    case null => -1
    case _    => parent.id
  }

  def childIds(): List[Int] = leftChild match {
    case null => Nil
    case _    => leftChild.id :: leftChild.rightSibIds
  }

  def rightSibIds(): List[Int] = rightSib match {
    case null => Nil
    case _    => rightSib.id :: rightSib.rightSibIds
  }

  def typeName(): String = {
    if (parent == null) return "root"
    if (childIds.isEmpty) return "leaf"
    return "internal node"
  }
}

object Main {
  def main(args: Array[String]) {
    val nNodes = StdIn.readInt
    val tree   = new Array[Node](nNodes).map {_ => new Node}
    
    1 to nNodes foreach {_ =>
      val inputs   = StdIn.readLine.split(" ").map { _.toInt }
      val id       = inputs.head
      val childIds = inputs.tail.tail

      val node = tree(id)
      node.id = id
      if (! childIds.isEmpty) {
        node.leftChild = tree( childIds(0) )
        for ( (childId, i) <- childIds.view.zipWithIndex) {
          val child    = tree(childId)
          child.parent = tree(id)
          if (i < childIds.size - 1) {
            child.rightSib = tree( childIds(i + 1) )
          }
        }
      }
    }

    tree.foreach {n =>
      val info = s"node ${n.id}: parent = ${n.parentId}, " +
        s"depth = ${n.depth}, ${n.typeName}, [${n.childIds.mkString(", ")}]"
        println(info)
    }
  }
}