class Node

  attr_accessor :id, :left_child, :right_sibling, :parent

  def initialize(id)
    @id= id
    @parent = -1
    @children = []
  end

  def get_depth
    depth = 0
    u = id
    until $tree[u].parent == -1 do
      depth += 1
      u = $tree[u].parent
    end
    depth
  end

  def get_height
    leaves = self.get_leaves
    depth = leaves.map{|i|$tree[i].get_depth}.max
    depth - $tree[self.id].get_depth
  end

  def get_leaves
    return [self.id] if self.get_type == 'leaf'
    children = get_children
    leaves = children.map do |child|
      $tree[child].get_leaves
    end
    leaves.flatten
  end

  def get_degree
    get_children.size
  end

  def get_children
    if left_child.nil?
      []
    else
      u = left_child
      children = [u]
      until $tree[u].right_sibling == nil do
        u = $tree[u].right_sibling
        children << u
      end
      children
    end
  end

  def get_sibling
    return -1 if parent == -1
    sibling = $tree[parent].get_children - [self.id]
    if sibling.empty?
      -1
    else
      sibling[0]
    end
  end

  def get_type
    if parent == -1
      'root'
    elsif get_children == []
      'leaf'
    else
      'internal node'
    end
  end
end

n = gets.to_i

$tree = {}

n.times do
  input = gets.split.map(&:to_i)
  id = input[0]
  left_child = input[1]
  right_child = input[2]

  children = [left_child, right_child].reject {|i| i == -1}
  children_count = children.size
  $tree[id] ||= Node.new(id)
  node = $tree[id]

  if children_count == 0
    node.left_child = nil
  else
    node.left_child = children[0]
    children.push(nil).each_cons(2) do |a, b|
      $tree[a] ||= Node.new(a)
      $tree[a].parent = id
      $tree[a].right_sibling = b if b
    end
  end
end


for i in 0..n - 1 do
  node = $tree[i]
  # node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root
  puts "node #{node.id}: parent = #{node.parent}, sibling = #{node.get_sibling}, degree = #{node.get_degree}, depth = #{node.get_depth}, height = #{node.get_height}, #{node.get_type}"
end

