#include <bits/stdc++.h>
using namespace std;
const int MN = 511;
const int MM = MN * MN;
const int oo = 1000111000;
int n, m, eu[MM], ev[MM], ec[MM];
int c[MN][MN], f[MN][MN];
int res[MN][MN], cnt[MN];
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(NULL);
  cout << (fixed) << setprecision(6);
  while (cin >> n >> m) {
    for (int i = (1), _b = (n); i <= _b; i++)
      for (int j = (1), _b = (n); j <= _b; j++) c[i][j] = oo;
    for (int i = (1), _b = (n); i <= _b; i++) c[i][i] = 0;
    for (int i = (1), _b = (m); i <= _b; i++) {
      cin >> eu[i] >> ev[i] >> ec[i];
      c[eu[i]][ev[i]] = min(c[eu[i]][ev[i]], ec[i]);
      c[ev[i]][eu[i]] = c[eu[i]][ev[i]];
    }
    for (int i = (1), _b = (n); i <= _b; i++)
      for (int j = (1), _b = (n); j <= _b; j++) f[i][j] = c[i][j];
    for (int k = (1), _b = (n); k <= _b; k++)
      for (int i = (1), _b = (n); i <= _b; i++)
        for (int j = (1), _b = (n); j <= _b; j++)
          f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
    memset(res, 0, sizeof res);
    for (int start = (1), _b = (n); start <= _b; start++) {
      for (int u = (1), _b = (n); u <= _b; u++)
        if (u == start)
          cnt[u] = 0;
        else {
          cnt[u] = 0;
          for (int v = (1), _b = (n); v <= _b; v++)
            if (u != v && f[start][u] == f[start][v] + c[v][u]) ++cnt[u];
        }
      for (int target = (1), _b = (n); target <= _b; target++)
        for (int u = (1), _b = (n); u <= _b; u++)
          if (f[start][u] + f[u][target] == f[start][target])
            res[start][target] += cnt[u];
    }
    for (int i = (1), _b = (n); i <= _b; i++)
      for (int j = (i + 1), _b = (n); j <= _b; j++)
        if (f[i][j] == oo) res[i][j] = 0;
    for (int i = (1), _b = (n); i <= _b; i++)
      for (int j = (i + 1), _b = (n); j <= _b; j++) cout << res[i][j] << ' ';
    cout << endl;
  }
  return 0;
}
