until (n = $<.gets.to_i).zero?
  m = $<.gets.to_i
  visited = []
  tourou = 0
  Array.new(m) {$<.gets.split(",").map(&:to_i)}.sort_by {|a| a.last}.each do |a, b, d|
    next if visited.include?(a) and visited.include?(b)
    visited = (visited + [a, b]).uniq
    tourou += d / 100 - 1
    break if visited.size == n
  end
  puts tourou
end
