class Node
  def initialize(node)
    @node = node
    @parent = -1
    @degree = 0
    @sibling = -1
    @left = -1
    @right = -1
    @depth = 0
    @height = 0
  end

  def who_am_i
    if parent == -1
      'root'
    elsif left == -1 && right == -1
      'leaf'
    else
      'internal node'
    end
  end

  def to_s
    "node #{node}: parent = #{parent}, sibling = #{sibling}, degree = #{degree}, depth = #{depth}, height = #{height}, #{who_am_i}"
  end

  attr_accessor :node, :parent, :left, :right, :depth, :sibling, :height, :degree
end

class BinaryTree
  def initialize(k)
    @node_list = []
    k.times do |i|
      node_list << Node.new(i)
    end
  end

  def create_node(index, left, right)
    node_list[index].left = left
    node_list[index].right = right
    if left != -1 && right != -1
      node_list[left].parent = index
      node_list[left].sibling = right
      node_list[right].parent = index
      node_list[right].sibling = left
    end
  end

  def eval_depth(index)
    return 0 if node_list[index].parent == -1
    eval_depth(node_list[index].parent) + 1
  end

  def eval_height(index)
    return 0 if node_list[index].left == -1 && node_list[index].right == -1
    left = node_list[index].left
    right = node_list[index].right
    left_height = eval_height(left)
    right_height = eval_height(right)
    if left_height > right_height
      left_height + 1
    else
      right_height + 1
    end
  end

  def eval_degree(index)
    count = 0
    node = node_list[index]
    count += 1 if node.left != -1
    count += 1 if node.right != -1
    count
  end

  def search_root_node
    node_list.each do |node|
      node.parent = -1 if node.parent.nil?
    end
  end

  attr_reader :node_list
end

n = gets.to_i
tree = BinaryTree.new n
n.times do
  input = gets.split(' ').map(&:to_i)
  tree.create_node input[0], input[1], input[2]
end
tree.node_list.each do |node|
  node.depth = tree.eval_depth node.node
  node.height = tree.eval_height node.node
  node.degree = tree.eval_degree node.node
end

puts tree.node_list.map(&:to_s)

