#include <bits/stdc++.h>
using namespace std;
const int N = 500, inF = 1e9;
int n, m, u, v, w, cnt[N][N], dp[N][N], edge[N][N];
vector<int> ans, nei[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) dp[i][j] = edge[i][j] = inF;
  for (int u = 0; u < n; u++) dp[u][u] = edge[u][u] = 0;
  while (m--) {
    cin >> u >> v >> w;
    dp[--u][--v] = dp[v][u] = min(dp[v][u], w);
    edge[u][v] = edge[v][u] = min(edge[u][v], w);
    nei[u].push_back(v);
    nei[v].push_back(u);
  }
  for (int i = 0; i < n; i++)
    for (int v = 0; v < n; v++)
      for (int u = 0; u < n; u++) dp[v][u] = min(dp[v][u], dp[v][i] + dp[i][u]);
  for (int u = 0; u < n; u++)
    for (int v = 0; v < n; v++)
      for (int w : nei[v])
        if (edge[w][v] + dp[w][u] == dp[v][u]) cnt[u][v]++;
  for (int u = 0; u < n; u++)
    for (int v = u + 1; v < n; v++) {
      int res = 0;
      for (int w = 0; w < n; w++)
        res += cnt[u][w] * (dp[w][u] + dp[w][v] == dp[u][v]);
      ans.push_back(res);
    }
  for (int num : ans) cout << num << ' ';
  return 0;
}
