#include <bits/stdc++.h>
using namespace std;
const int N = 500;
int d[N][N], s[N][N], n, m;
int main(void) {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) s[i][j] = -1;
  for (int i = 0; i < n; i++) s[i][i] = 0;
  for (int i = 0; i < m; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    u--, v--;
    s[u][v] = s[v][u] = c;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) d[i][j] = s[i][j];
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j) continue;
        if (d[i][k] != -1 && d[k][j] != -1) {
          if (d[i][j] != -1)
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
          else
            d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
  vector<int> vset, indeg;
  indeg.resize(n);
  for (int i = 0; i < n; i++) {
    fill(indeg.begin(), indeg.end(), 0);
    for (int j = 0; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        int u = j, v = k;
        if (d[i][u] == -1 || d[i][v] == -1) continue;
        if (d[i][u] > d[i][v]) swap(u, v);
        if (d[i][v] == d[i][u] + s[u][v]) indeg[v]++;
      }
    }
    for (int j = i + 1; j < n; j++) {
      vset.clear();
      for (int k = 0; k < n; k++) {
        if (d[i][j] != -1 && d[i][j] == d[i][k] + d[k][j]) {
          vset.push_back(k);
        }
      }
      int ans = 0;
      for (int k = 0; k < vset.size(); k++) {
        ans += indeg[vset[k]];
      }
      cout << ans << " ";
    }
  }
  cout << endl;
  return 0;
}
