#include <bits/stdc++.h>
using namespace std;
const int mxn = 5e2 + 5;
const long long inf = 1e18;
const int mod = 1e9 + 7;
inline int pw(int x, int y) {
  int r = 1;
  while (y) {
    if (y & 1) r = 1LL * r * x % mod;
    x = 1LL * x * x % mod;
    y >>= 1;
  }
  return r;
}
long long n, m, dis[mxn][mxn], sum[mxn][mxn], w[mxn][mxn];
vector<long long> g[mxn];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dis[i][j] = inf;
    }
    dis[i][i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    g[x].push_back(y);
    g[y].push_back(x);
    dis[x][y] = z;
    dis[y][x] = z;
    w[x][y] = w[y][x] = z;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        dis[i][j] = min(dis[i][k] + dis[k][j], dis[i][j]);
      }
    }
  }
  for (int s = 1; s <= n; s++) {
    for (int t = 1; t <= n; t++) {
      for (auto u : g[t]) {
        if (dis[s][t] == dis[s][u] + w[u][t]) {
          sum[s][t]++;
        }
      }
    }
  }
  for (int s = 1; s <= n; s++) {
    for (int t = s + 1; t <= n; t++) {
      int ans = 0;
      for (int i = 1; i <= n; i++) {
        if (dis[s][t] == dis[s][i] + dis[i][t]) ans += sum[s][i];
      }
      cout << ans << " ";
    }
  }
  return 0;
}
