import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

object Main {
  val NIL = -1

  class Node(var parent:Int = NIL,var left:Int = NIL,var right:Int = NIL) { }

  def main(args:Array[String]) = {
    val n = readInt
    val tree = (0 until n).map(_=>new Node).toArray
    val depth = new Array[Int](n)

    for(i<-0 until n) {
      val s = readLine.split(" ").map(_.toInt)
      val id = s(0)
      val k = s(1)
      var prev = 0
      for(j<-2 until k+2) {
        if(j==2) tree(id).left = s(j)
        else tree(prev).right = s(j)
        prev = s(j)
        tree(s(j)).parent = id
      }
    }

    def getDepth(node:Int,d:Int):Unit = {
      depth(node) = d
      if( tree(node).right != NIL ) getDepth(tree(node).right, d)
      if( tree(node).left != NIL ) getDepth(tree(node).left, d+1)
    }

    val root = tree.indexWhere(_.parent == NIL)
    getDepth(root, 0)

    for(i<-0 until n) {
      print("node " + i + ": ")
      print("parent = " + tree(i).parent + ", ")
      print("depth = " + depth(i) + ", ")
      if( tree(i).parent == NIL ) print("root, ")
      else if( tree(i).left == NIL ) print("leaf, ")
      else print("internal node, ")

      print("[")

      var node = tree(i).left
      val a = new ArrayBuffer[Int]
      while(node!=NIL) {
        a.append(node)
        node = tree(node).right
      }
      print(a.mkString(", "))
      println("]")
    }
  }
}