#include <cstdio>
#include <cstring>
#include <climits>
#include <algorithm>
using namespace std;

int n;
int s[100][100];
bool b[100];
bool c[100];
int ans;
int cc;

void dfs(int x, int y, int sum) {
  /*for (int i=0; i<n; i++) {
    printf("%d ", b[i]);
  }
  printf("\n");*/
  //printf("%d %d %d %d [%d %d %d %d]\n", x, y, sum, cc, c[0], c[1], c[2], c[3]);
  if (s[x][y] && !b[y] && !c[y]) {
    //printf("use %d-%d\n", x, y);
    if (cc == n-1) {
      //printf("%d\n", sum+s[x][y]);
      ans = min(ans, sum+s[x][y]);
    } else {
      b[y] = true;
      ++cc;
      if (y < n-1) dfs(x, y+1, sum+s[x][y]);
      else {
        bool ct[n];
        //printf("save %d %d %d %d\n", c[0], c[1], c[2], c[3]);
        memcpy(ct, c, sizeof(bool)*n);
        for (int i=0; i<n; i++) {
          if (!c[i] && b[i]) {
            c[i] = true;
            //printf("check %d start\n", i);
            dfs(i, 0, sum+s[x][y]);
            //printf("check %d end\n", i);
          }
        }
        //printf("revert %d %d %d %d\n", ct[0], ct[1], ct[2], ct[3]);
        memcpy(c, ct, sizeof(bool)*n);
      }
      b[y] = false;
      --cc;
    }
    //printf("unuse %d-%d\n", x, y);
  }
  if (y < n-1) dfs(x, y+1, sum);
  else {
    bool ct[n];
        //printf("save %d %d %d %d\n", c[0], c[1], c[2], c[3]);
    memcpy(ct, c, sizeof(bool)*n);
    for (int i=0; i<n; i++) {
      if (!c[i] && b[i]) {
        c[i] = true;
        //printf("check %d start\n", i);
        dfs(i, 0, sum);
        //printf("check %d end\n", i);
      }
    }
        //printf("revert %d %d %d %d\n", ct[0], ct[1], ct[2], ct[3]);
    memcpy(c, ct, sizeof(bool)*n);
  }
}

int main() {
  int m, x, y, z;

  while (1) {
    scanf("%d", &n);
    if (!n) break;
    memset(b, 0, sizeof(bool)*n);
    memset(c, 0, sizeof(bool)*n);
    memset(s, 0, sizeof(int)*n*100);
    scanf("%d", &m);
    for (int i=0; i<m; i++) {
      scanf("%d,%d,%d", &x, &y, &z);
      s[x][y] = s[y][x] = z/100-1;
    }
    b[0] = true;
    c[0] = true;
    ans = INT_MAX;
    cc = 1;
    dfs(0, 0, 0);
    printf("%d\n", ans);
  }
}