#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(10);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > f(n, vector<int>(n, 1e9)), g(n, vector<int>(n, 0));
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    f[u][v] = f[v][u] = w;
  }
  auto h = f;
  for (int i = 0; i < n; ++i) {
    f[i][i] = 0;
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
      }
    }
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (f[i][k] + h[k][j] == f[i][j]) g[i][j]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (f[i][j] == 1e9) {
        cout << 0 << " ";
        continue;
      }
      int res = 0;
      for (int k = 0; k < n; k++) {
        if (i == k) continue;
        if (f[i][k] + f[k][j] == f[i][j]) res += g[i][k];
      }
      cout << res << " ";
    }
  }
  cout << "\n";
  return 0;
}
