until (n = $<.gets.to_i).zero?
  m = $<.gets.to_i
  init_spots = Array.new(m, 0)
  tourou = 0
  table = Array.new(m) {$<.gets.split(",").map(&:to_i)}.map do |a, b, d|
    init_spots[a] += 1
    init_spots[b] += 1
    n = d / 100 - 1
    tourou += n
    [a, b, n]
  end
  min = tourou
  solve = ->(i, spots, t) {
    min = t if t < min
    return if i == m
    solve.(i + 1, spots, t)
    now = table[i]
    return if spots[now[0]] == 1 or spots[now[1]] == 1
    spots[now[0]] -= 1
    spots[now[1]] -= 1
    solve.(i + 1, spots, t - now[2])
    spots[now[0]] += 1
    spots[now[1]] += 1
  }
  solve.(0, init_spots, tourou)
  puts min
end
