#include <bits/stdc++.h>
int min(int a, int b) { return a < b ? a : b; }
int main() {
  static int aa[500][500], dd[500][500], kk[500][500];
  int n, m, s, i, j, k, t;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) aa[i][j] = 0x3f3f3f3f;
    aa[i][i] = 0;
  }
  while (m--) {
    int a;
    scanf("%d%d%d", &i, &j, &a), i--, j--;
    aa[i][j] = aa[j][i] = a;
  }
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) dd[i][j] = aa[i][j];
  for (k = 0; k < n; k++)
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) dd[i][j] = min(dd[i][j], dd[i][k] + dd[k][j]);
  for (s = 0; s < n; s++)
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++)
        if (i != j && dd[s][i] + aa[i][j] == dd[s][j]) kk[s][j]++;
  for (s = 0; s < n; s++)
    for (t = s + 1; t < n; t++) {
      int d = dd[s][t];
      k = 0;
      if (d != 0x3f3f3f3f)
        for (j = 0; j < n; j++)
          if (dd[s][j] + dd[j][t] == d) k += kk[s][j];
      printf("%d ", k);
    }
  printf("\n");
  return 0;
}
