#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
int i, j, k, m, n, s, t;
const int N = 5e2 + 10;
int dp[N][N], mp[N][N], f[N][N];
map<int, short> p[N][N];
signed main() {
  read(n), read(m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) dp[i][j] = mp[i][j] = 1e9;
  for (i = 1; i <= n; i++) dp[i][i] = mp[i][i] = 0;
  for (i = 1; i <= m; i++) {
    int x, y, z;
    read(x), read(y), read(z);
    mp[x][y] = dp[x][y] = z;
    mp[y][x] = dp[y][x] = z;
  }
  for (k = 1; k <= n; k++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) {
        if (i == j || j == k || i == k) continue;
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      for (k = 1; k <= n; k++)
        if (mp[i][j] <= 1e8 && i != j && mp[i][j] + dp[j][k] == dp[i][k])
          p[i][k][mp[i][j] + dp[j][k]]++;
  for (i = 1; i <= n; i++)
    for (j = i + 1; j <= n; j++)
      for (k = 1; k <= n; k++)
        if (dp[i][j] == dp[i][k] + dp[k][j])
          f[i][j] += p[k][j][dp[i][j] - dp[i][k]];
  for (i = 1; i <= n; i++)
    for (j = i + 1; j <= n; j++) printf("%d ", f[i][j]);
  return 0;
}
