class Node
  attr_reader :id, :left, :right
  attr_writer :parent
 
  def initialize(id)
    @id = id
    @parent = nil
    @left = @right = nil
  end
 
  def left=(child)
    @left = child
    child.parent = self
  end

  def right=(child)
    @right = child
    child.parent = self
  end
 
  def type
    return 'root' if @parent.nil?
    return 'leaf' if @left.nil? && @right.nil?
    'internal node'
  end
 
  def parent_id
    return -1 if @parent.nil?
    @parent.id
  end
 
  def depth
    return 0 if @parent.nil?
    1 + @parent.depth
  end

  def degree
    deg = 0
    deg += 1 unless @left.nil?
    deg += 1 unless @right.nil?
    deg
  end

  def sibling_id
    return -1 if @parent.nil?
    s = (@parent.left == self ? @parent.right : @parent.left)
    s.nil? ? -1 : s.id
  end

  def height
    return 0 if @left.nil? && @right.nil?
    hl = @left.nil? ? 0 : @left.height
    hr = @right.nil? ? 0 : @right.height
    1 + [hl, hr].max
  end
end
 
n = gets.to_i
nodes = n.times.map{|id| Node.new(id) }
 
n.times do
  id, left_id, right_id = gets.split.map(&:to_i)
  node = nodes[id]
  node.left = nodes[left_id] unless left_id == -1
  node.right = nodes[right_id] unless right_id == -1
end
 
nodes.each do |n|
  puts "node #{n.id}: parent = #{n.parent_id}, sibling = #{n.sibling_id}, degree = #{n.degree}, depth = #{n.depth}, height = #{n.height}, #{n.type}"
end