#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

class data {
	public:
		int a, b;
		int c;

		data(int p1, int p2, int cost) {
			a = p1;
			b = p2;
			c = cost;
		}

		bool operator<(const data & c_) const {
			return c < c_.c;
		}
};

int n, m;
vector<data> cost;
vector<data> modefied_cost;
vector<vector<int> > used_point;

void init() {
	cost.clear();
	modefied_cost.clear();
	used_point.clear();
}

bool input() {
	cin >> n;
	if(!n)
		return false;

	cin >> m;
	for(int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d,%d,%d", &a, &b, &c);
		cost.push_back(data(a, b, c));
	}

	return true;
}

void modefy_cost() {
	for(int i = 0; i < cost.size(); i++) {
		modefied_cost.push_back(data(cost[i].a, cost[i].b, cost[i].c / 100 - 1));
	}
}

pair<pair<int,int>,pair<int,int> > find_point(const data & d) {
	pair<pair<int, int>, pair<int, int> > ij_pair(pair<int,int>(-1, -1), pair<int,int>(-2, -2));
	for(int i = 0; i < used_point.size(); i++) {
		for(int j = 0; j < used_point[i].size(); j++) {
			if(used_point[i][j] == d.a) {
				ij_pair.first.first = i;
				ij_pair.first.second = j;
			}
			else if(used_point[i][j] == d.b) {
				ij_pair.second.first = i;
				ij_pair.second.second = j;
			}
		}
	}

	return ij_pair;
}

int solve() {
	modefy_cost();
	sort(modefied_cost.begin(), modefied_cost.end());
	int ans = 0;

	for(int i = 0; i < modefied_cost.size(); i++) {
		pair<pair<int,int>,pair<int,int> > tmp;
		tmp = find_point(modefied_cost[i]);

		if(tmp.first.first == tmp.second.first) {
			continue;
		}

		else if(tmp.first.first > -1 && tmp.second.first < 0) {
			used_point[tmp.first.first].push_back(modefied_cost[i].b);
			ans += modefied_cost[i].c;
		}
		else if(tmp.first.first < 0 && tmp.second.first > -1) {
			used_point[tmp.second.first].push_back(modefied_cost[i].a);
			ans += modefied_cost[i].c;
		}
		else if(tmp.first.first > -1 && tmp.second.first > -1) {
			used_point[tmp.first.first].insert(used_point[tmp.first.first].end(),
					used_point[tmp.second.first].begin(), used_point[tmp.second.first].end());
			used_point.erase(used_point.begin() + tmp.second.first, used_point.begin() + tmp.second.first + 1);
			ans += modefied_cost[i].c;
		}
		else {
			used_point.push_back(vector<int>(2));
			used_point[used_point.size() - 1][0] = modefied_cost[i].a;
			used_point[used_point.size() - 1][1] = modefied_cost[i].b;
			ans += modefied_cost[i].c;
		}
	}
	return ans;
}

int main() {
	while(init(), input()) {
		cout << solve() << endl;
	}
}