#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e2 + 10;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
vector<pair<long long, long long> > G[maxn];
long long dp[maxn][maxn], a[maxn][maxn], ans[maxn][maxn], u, v, w;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  memset(dp, 63, sizeof(dp));
  for (int i = 1; i <= n; i++) dp[i][i] = 0;
  for (int i = 0; i != m; i++) {
    cin >> u >> v >> w;
    G[u].push_back({v, w});
    G[v].push_back({u, w});
    dp[u][v] = w;
    dp[v][u] = w;
  }
  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 = 0; k != G[i].size(); k++) {
        if (dp[i][j] == G[i][k].second + dp[G[i][k].first][j]) {
          a[i][j]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        if (k == j) continue;
        if (dp[i][j] == dp[i][k] + dp[k][j]) {
          ans[i][j] += a[k][j];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      cout << ans[i][j] << " ";
    }
  }
  return 0;
}
