class Node
  attr_accessor :id, :parent, :left, :right, :depth

  def initialize(id)
    @id = id
    @parent = -1
    @left = nil
    @right = nil
  end

  def add_left(left);
    @left = left
    @left.parent = self
  end

  def add_right(right);
    @right = right
    @right.parent = self
  end

  def to_s
    "#{@id}"
  end

  # ----
  def sibling
    return -1 if @parent == -1
    if @parent.left == self
      return @parent.right ? @parent.right : -1
    elsif @parent.right == self
      return @parent.left ? @parent.left : -1
    end
  end

  def degree
    if @right and @left
      degree = 2
    elsif @right or @left
      degree = 1
    else
      degree = 0
    end
    degree
  end

  def type
    if @parent == -1
      type = 'root'
    elsif @left or @right
      type = 'internal node'
    else
      type = 'leaf'
    end
    type
  end

  def set_depth(n)
    @depth = n
    @left.set_depth(@depth + 1) if @left
    @right.set_depth(@depth + 1) if @right
  end

  def height
    lh = @left  ? @left.height  : -1
    rh = @right ? @right.height : -1
    ret = lh > rh ? lh + 1 : rh + 1
  end

end

n = gets.to_i
tree = Array.new(n){ | i | Node.new(i) }
n.times do
  id, l, r = gets.split.map(&:to_i)
  tree[id].add_left(tree[l])  if l != -1
  tree[id].add_right(tree[r]) if r != -1
end

root = nil
tree.each{ |n| root = n if n.parent == -1 }
root.set_depth(0)

tree.each do | n |
  print "node #{n.id}: "
  print "parent = #{n.parent}, "
  print "sibling = #{n.sibling}, "
  print "degree = #{n.degree}, "
  print "depth = #{n.depth}, "
  print "height = #{n.height}, "
  print "#{n.type}"
  puts ''
end
