#include <bits/stdc++.h>
using namespace std;
int o, n, m, u, v, d[569][2], c[569][569], w[569][569], dp[569][569], cnt;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i != j) dp[i][j] = 1e9 + 1;
      w[i][j] = 1e9 + 1;
    }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &o);
    w[v][u] = w[u][v] = o;
    dp[v][u] = dp[u][v] = w[u][v];
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++) {
        if (dp[i][j] == 1e9 + 1) continue;
        if (dp[i][k] + w[k][j] == dp[i][j]) c[i][j]++;
      }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      cnt = 0;
      for (int k = 1; k <= n; k++) {
        if (dp[i][k] + dp[k][j] == dp[i][j]) cnt += c[i][k];
      }
      cout << cnt << " ";
    }
}
