#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 500 + 6.9;
const long long INF = 1e18;
long long dist[MAXN][MAXN];
long long tail[MAXN];
long long ans[MAXN];
vector<pair<long long, long long>> a[MAXN];
long long n, m;
void floyd() {
  for (long long k = 1; k <= n; k++) {
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[j][k]);
      }
    }
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (i == j) continue;
      dist[i][j] = INF;
    }
  }
  for (long long i = 1; i <= m; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    dist[x][y] = dist[y][x] = z;
    a[x].push_back({y, z});
    a[y].push_back({x, z});
  }
  floyd();
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) tail[j] = ans[j] = 0;
    for (long long j = 1; j <= n; j++) {
      for (auto u : a[j]) {
        if (dist[i][u.first] + u.second == dist[i][j]) tail[j]++;
      }
    }
    for (long long j = 1; j <= n; j++) {
      for (long long k = 1; k <= n; k++) {
        if (dist[i][k] + dist[k][j] == dist[i][j]) ans[j] += tail[k];
      }
    }
    for (long long j = i + 1; j <= n; j++) cout << ans[j] << ' ';
  }
}
