class Node
  def initialize(id)
    @id = id
    @parent = -1
    @sibling = -1
    @depth = 0
    @height = 0
    @type = nil
    @children = []
  end

  attr_accessor :id, :parent, :sibling, :depth, :height, :type, :children

  def degree
    return @children.size
  end
end

def find_root(node_map)
  node_index = node_map.values.index {|item| item.degree == 0}
  parent_index = node_index
  while parent_index > -1 
    node_index = parent_index
    parent_index = $node_map[node_index].parent
  end
  return $node_map[node_index]
end

def assign(node, depth)
  if (node.parent == -1) then
    node.type = "root"
  else
    node.type = (node.children.size > 0) ? "internal node" : "leaf"
  end

  if (node.children.size == 2) then
    $node_map[node.children[0]].sibling = node.children[1]
    $node_map[node.children[1]].sibling = node.children[0]
  end

  node.depth = depth

  node.children.each do |index|
    assign($node_map[index], depth+1)
  end
end

def assign_height(node_map)
  node_map.values.each do |node|
    if node.type == "leaf" then
      height = 0
      parent_node = node
      while parent_node.parent > -1
        parent_node = node_map[parent_node.parent]
        height += 1
        parent_node.height = [parent_node.height, height].max
      end
    end
  end
end

n = gets.chomp.to_i
$node_map = {}
n.times do |index|
  $node_map[index] = Node.new(index)
end

n.times do
  array = gets.chomp.split.map(&:to_i)
  array[1..2].each do |item|
    if (item > -1) then
      $node_map[array[0]].children << item
      $node_map[item].parent = array[0]
    end
  end
end

root = find_root($node_map)
assign(root, 0)
assign_height($node_map)

$node_map.each do |key, node|
  puts "node #{node.id}: parent = #{node.parent}, sibling = #{node.sibling}, degree = #{node.degree}, depth = #{node.depth}, height = #{node.height}, #{node.type}"
end