#include <bits/stdc++.h>
using namespace std;
const int N = 505, mod = 1e9 + 7, Inf = 1e9;
int t, n, m, dist[N][N], cnt[N][N];
vector<pair<int, int> > V[N];
string second;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) dist[i][j] = Inf;
    dist[i][i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    dist[u][v] = dist[v][u] = w;
    V[v].push_back({u, w});
    V[u].push_back({v, w});
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 0; k < V[j].size(); k++)
        if (dist[i][j] == dist[i][V[j][k].first] + V[j][k].second) cnt[i][j]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int ans = 0;
      for (int k = 1; k <= n; k++) {
        if (dist[i][j] == dist[i][k] + dist[j][k]) ans += cnt[i][k];
      }
      cout << ans << " ";
    }
  }
}
