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

object Main {
  val NIL = -1

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

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

    for(i<-0 until n) {
      val s = readLine.split(" ").map(_.toInt)
      tree(s(0)).left = s(1)
      tree(s(0)).right = s(2)
      if(s(1) != NIL) tree(s(1)).parent = s(0)
      if(s(2) != NIL) tree(s(2)).parent = s(0)
    }

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

    def setHeight(id:Int):Int = {
      val hr:Int = if(tree(id).right != NIL) setHeight(tree(id).right) + 1 else 0
      val hl:Int = if(tree(id).left != NIL) setHeight(tree(id).left) + 1 else 0
      val x = if(hl>hr) hl else hr
      tree(id).height = x
      x
    }

    def getSibling(id:Int):Int = {
      if(tree(id).parent == NIL) NIL
      else {
        val parentNode = tree(tree(id).parent)
        if(parentNode.left != id && parentNode.left != NIL) parentNode.left
        else if(parentNode.right != id && parentNode.right != NIL) parentNode.right
        else NIL
      }
    }

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

    for(i<-0 until n) {
      print("node " + i + ": ")
      print("parent = " + tree(i).parent + ", ")
      print("sibling = " + getSibling(i) + ", ")
      val (l,r) = (if(tree(i).left != NIL) 1 else 0, if(tree(i).right != NIL) 1 else 0)
      print("degree = " + (l+r) + ", ")
      print("depth = " + tree(i).depth + ", ")
      print("height = " + tree(i).height+ ", ")
      if(tree(i).parent == NIL) println("root")
      else if(tree(i).left == NIL && tree(i).right == NIL) println("leaf")
      else println("internal node")
    }
  }
}