#include <bits/stdc++.h>
using namespace std;
const int inf = 1000 * 1000 * 1000;
int n, m, s[505][505], d[505][505], w[505][505];
int main() {
  memset(s, 0x3f, sizeof s);
  memset(d, 0x3f, sizeof d);
  scanf("%d%d", &n, &m);
  for (int i = 0, u, v, l; i < m; ++i)
    scanf("%d%d%d", &u, &v, &l), s[u][v] = s[v][u] = l, d[u][v] = d[v][u] = l;
  for (int i = 1; i <= n; ++i) s[i][i] = d[i][i] = 0;
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) {
        if (s[i][k] + s[k][j] < s[i][j]) s[i][j] = s[i][k] + s[k][j];
      }
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) {
        if (j != k && i != j && s[i][k] + d[k][j] == s[i][j]) w[i][j]++;
      }
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      int ans = 0;
      if (s[i][j] < inf)
        for (int k = 1; k <= n; ++k)
          if (s[i][k] + s[k][j] == s[i][j]) ans += w[i][k];
      printf("%d ", ans);
    }
  }
}
