#include <bits/stdc++.h>
using namespace std;
const int maxN = 500 + 13;
int n, m, dis[maxN][maxN], inedge[maxN][maxN], ans[maxN][maxN];
vector<pair<pair<int, int>, int>> edge;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  memset(dis, 63, sizeof dis);
  for (int i = 0; i < m; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    edge.push_back({{a, b}, w});
    dis[a][b] = w;
    dis[b][a] = w;
  }
  for (int i = 1; i <= n; i++) dis[i][i] = 0;
  for (int d = 1; d <= n; d++)
    for (int v = 1; v <= n; v++)
      for (int u = 1; u <= n; u++)
        dis[v][u] = min(dis[v][u], dis[v][d] + dis[d][u]);
  for (int i = 1; i <= n; i++)
    for (auto a : edge) {
      int u = a.first.first, v = a.first.second, w = a.second;
      if (dis[i][u] + w == dis[i][v]) inedge[i][v]++;
      if (dis[i][v] + w == dis[i][u]) inedge[i][u]++;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int mid = 1; mid <= n; mid++)
        if (dis[i][mid] + dis[mid][j] == dis[i][j]) ans[i][j] += inedge[i][mid];
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      cout << ans[i][j] << " ";
    }
}
