#include <bits/stdc++.h>
using namespace std;
const int N = 510;
int t, n, m, a, b, c;
vector<pair<int, int> > g[N];
int dp[N][N], inDegree[N][N], source, ans[N][N];
bool vis[N];
void dfs(int u) {
  if (vis[u]) return;
  vis[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first;
    int newCost = g[u][i].second + dp[source][u];
    if (dp[source][v] == newCost) {
      inDegree[source][v]++;
      dfs(v);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = 1e9;
    }
    dp[i][i] = 0;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
    dp[a][b] = min(dp[a][b], c);
    dp[b][a] = min(dp[b][a], c);
  }
  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 (source = 1; source <= n; source++) {
    memset(vis, 0, sizeof vis);
    dfs(source);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        if (dp[i][k] + dp[k][j] == dp[i][j]) {
          ans[i][j] += inDegree[i][k];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      printf("%d ", ans[i][j]);
    }
  }
  puts("");
  return 0;
}
