class Node
  attr_accessor :id, :children, :parent_id

  def initialize id
    @id = id.to_i
    @children = []
    @parent_id = -1
  end

  def setChild child_id
    @children << child_id
  end

  def setParent parent_id
    @parent_id = parent_id
  end
end

$input_map = {}
n = 0
count = 0
line_count = 0
STDIN.each_line {|line|
  if count == 0
    count += 1
    n = line.to_i
    next
  end

  hoge = 0
  array = line.split " "
  id = array[0].to_i
  $input_map[id] = Node.new id
  array.each do |num|
    hoge += 1
    if hoge==1
      # n = num.to_i
      next
    elsif hoge==2
      next
    end

    $input_map[id].setChild num.to_i
  end

  line_count += 1
}

# set parent
$input_map.each_pair { |id, node|
  node.children.each do |child_id|
    $input_map[child_id].setParent id
  end
}

# search root
root_id = -1
$input_map.each_pair { |id, node|
  if node.parent_id == -1
    root_id = id
    break
  end
}

$print_list = Array.new n
def PrintNode id, parent_id, depth
  child_str = ""
  type = depth == 0 ? "root" : "internal node"
  if $input_map[id].children.empty?
    type = "leaf"
  else
    child_str = $input_map[id].children.join ", "
  end

  $print_list[id] = "node ", id, ": parant = ", parent_id, ", depth = ", depth, ", ", type, ", ", "[", child_str ,"]\n"

  $input_map[id].children.each do |child_id|
    PrintNode child_id, id, depth + 1
  end
end

PrintNode root_id.to_i, -1, 0
n.times do |i|
    print $print_list[i].join ""
end

