#include <bits/stdc++.h>
using namespace std;
const long long N = 5e2 + 10, inf = 1e14;
long long n, m, x, y, w;
long long dp[N][N], r[N], d[N][N];
vector<pair<long long, long long> > v[N];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) dp[i][j] = inf;
  for (int i = 1; i <= n; i++) dp[i][i] = 0;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y >> w;
    v[x].push_back({y, w});
    v[y].push_back({x, w});
    dp[x][y] = min(dp[x][y], w);
    dp[y][x] = min(dp[y][x], 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 k = 1; k <= n; k++) {
    fill(r, r + N, 0);
    for (int i = 1; i <= n; i++) {
      for (auto xd : v[i]) {
        y = xd.first;
        w = xd.second;
        if (dp[k][y] == dp[k][i] + w) r[y]++;
      }
    }
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (dp[k][j] == dp[k][i] + dp[i][j] && k < j) d[k][j] += r[i];
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) cout << d[i][j] << ' ';
  cout << '\n';
  return 0;
}
