#include<iostream>
#include<algorithm>
using namespace std;
int G[102][102];
int NG[102][102];
bool used[102];
const int INF=9999999;
int main(){
	int n,m,ans=0;
	while(true){
	cin>>n;
	if(n==0)break;
	cin>>m;
	ans=0;
	for(int i=0;i<102;i++)for(int j=0;j<102;j++)G[i][j]=INF,used[i]=false,NG[i][j]=INF;
	for(int i=0;i<m;i++){
		int a,b,c;
		char x;
		cin>>a>>x>>b>>x>>c;
		if(a==b){cout<<"x";return 0;}
		G[a][b]=c;
	}
	int u,v,a,b;
	used[0]=1;
	for(int i=0;i<n;i++){
		v=-1;
		for(int j=0;j<n;j++)if(!used[j])v=1;
		if(v==-1)break;
		int mi=INF;
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
			if(mi>G[j][k]&&used[j]==1&&used[k]==0)mi=G[j][k],a=j,b=k;
			}
		}
		used[b]=1;
		//cout<<a<<" "<<b<<endl;
		//for(int i=0;i<n;i++)cout<<used[i]<<" ";cout<<endl;
		NG[a][b]=G[a][b];
		ans+=G[a][b]-100;
	}
//for(int i=0;i<n;i++){for(int j=0;j<n;j++)cout<<G[i][j]<<" ";cout<<endl;}
//	for(int i=0;i<n;i++){for(int j=0;j<n;j++)cout<<NG[i][j]<<" ";cout<<endl;}
	//for(int i=0;i<n;i++)for(int j=0;j<n;j++)ans+=NG[i][j];
	cout<<ans/100<<endl;
	}
	return 0;
}