import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn

object Main extends App {

  final val nil = -1
  
  case class Node(var parent: Int = -1,var left: Int = -1, var right: Int = -1){
    
    def typeInfo: String = if(parent == -1) {
      "root"
    } else if(left == nil ) {
      "leaf"
    } else {
      "internal node"
    }
    
    def nodeLiteral(depth: Int, childs: Array[Int]): String = {
      s"parent = $parent, depth = $depth, $typeInfo, [${childs.mkString(", ")}]"
    }
    override def toString: String = s"parent = $parent, depth = X, $typeInfo, [child]"
    
  }
  
  def setDepth(index: Int, cnt: Int): Unit = {
    //println("setDepth:" + index)
    depth(index) = cnt
    if(input(index).right != nil){ // brother
      setDepth(input(index).right, cnt)
    }
    if(input(index).left != nil){ // child
      setDepth(input(index).left, cnt + 1)
    }
  }
  
  def getChild(index: Int): Array[Int] = {
    if(input(index).left == nil){
      Array.empty[Int]
    } else {
      var node = input(input(index).left)
      var ret = ArrayBuffer(input(index).left)
      while(node.right != nil){
        ret += node.right
        node = input(node.right)
      }
      ret.toArray
    }
  }
  
  val n = StdIn.readLine().trim.toInt
  val input = Array.fill[Node](n)(null)
  val depth = Array.fill[Int](n)(0)

  (0 until n).foreach{ _ =>
    val a = StdIn.readLine().trim.split(" ").map(_.toInt)
    val i = a(0)
    val c = a.drop(2)
    var before: Int = -1
    input(i) = if(input(i) == null) Node(nil, nil, nil) else input(i)
    c.zipWithIndex.foreach{ ci =>
      input(ci._1) = if(input(ci._1) == null) Node(i, nil, nil) else input(ci._1)
      
      if(ci._2 == 0) {
        input(i).left =  ci._1
      }
      
      if(before != nil){
        input(before).right = ci._1
      }
      before = ci._1
      input(ci._1).parent = i
    }
    
    
  }

  var root = nil
  (0 until n).foreach{ i =>
    //println(s"$i:" + input(i))
    if(input(i).parent == nil) root = i
  }
  
  setDepth(root, 0)
  
  (0 until n).foreach{ i =>
    val ch = getChild(i)
    println(s"node $i: " + input(i).nodeLiteral(depth(i), ch))
  }

}
