#include <bits/stdc++.h>
int map[505][505], c[505][505], dis[505][505];
int min(int a, int b) { return a > b ? b : a; }
int main() {
  int n, m, i, j, k, l, a, b, ans;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(c, 0, sizeof(c));
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) {
        if (i == j)
          map[i][j] = dis[i][j] = 0;
        else
          map[i][j] = dis[i][j] = 200000000;
      }
    for (i = 1; i <= m; i++) {
      scanf("%d%d%d", &a, &b, &l);
      map[a][b] = map[b][a] = dis[a][b] = dis[b][a] = l;
    }
    for (k = 1; k <= n; k++)
      for (i = 1; i <= n; i++)
        for (j = 1; j <= n; j++)
          dis[i][j] = min(dis[i][k] + dis[k][j], dis[i][j]);
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++)
        for (k = 1; k <= n; k++)
          if (map[k][j] && map[k][j] + dis[i][k] == dis[i][j] &&
              dis[i][j] < 200000000)
            c[i][j]++;
    for (i = 1; i < n; i++)
      for (j = i + 1; j <= n; j++) {
        ans = 0;
        for (k = 1; k <= n; k++) {
          if (dis[i][k] + dis[k][j] == dis[i][j]) ans += c[i][k];
        }
        if (i == n - 1 && j == n)
          printf("%d\n", ans);
        else
          printf("%d ", ans);
      }
  }
  return 0;
}
