#include <iostream>
#include <vector>
#include <algorithm>

constexpr int MAX_N = 100;

struct edge {
	int from_, to_, cost_;
	edge() = default;
	edge(int from, int to, int cost) :from_(from), to_(to), cost_(cost) {}
	bool operator<(const edge& rhs) const{
		return cost_ < rhs.cost_;
	}
};

int n, m;
std::vector<edge> edges;

class Union {
	int par[MAX_N], rank[MAX_N];
public:
	Union() {
		for (int i = 0; i < n; ++i) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int find(int x) {
		if (x == par[x])
			return x;
		par[x] = find(par[x]);
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank[x] < rank[y])
			std::swap(x, y);
		par[y] = x;
		rank[x] += rank[y];
	}
};

int main() {
	while (1) {
		std::cin >> n;
		if (!n)
			break;
		std::cin >> m;
		Union uni;
		edges.clear();
		int a, b, d;
		char ch;
		for (int i = 0; i < m; ++i) {
			std::cin >> a >> ch >> b >> ch >> d;
			d /= 100;
			--d;
			edges.emplace_back(a, b, d);
		}

		std::sort(edges.begin(), edges.end());

		int ans = 0;
		for (int i = 0; i < edges.size(); ++i) {
			if (!uni.same(edges[i].from_, edges[i].to_)) {
				uni.unite(edges[i].from_, edges[i].to_);
				ans += edges[i].cost_;
				std::cout << edges[i].cost_ << std::endl;
			}
		}
		std::cout << ans << std::endl;
	}
	return 0;
}