#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m, len, path[502][502], cnt[502][502], dist[502][502];
  cin >> n >> m;
  memset(cnt, 0, sizeof(cnt));
  for (long i = 1; i <= n; i++)
    for (long j = 1; j <= n; j++) {
      if (i == j)
        dist[i][i] = 0;
      else
        dist[i][j] = 0x3fffffff;
    }
  long u, v;
  for (long i = 1; i <= m; i++) {
    cin >> u >> v >> len;
    dist[u][v] = dist[v][u] = path[u][v] = path[v][u] = len;
  }
  for (long k = 1; k <= n; k++)
    for (long i = 1; i <= n; i++)
      for (long j = 1; j <= n; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  for (long i = 1; i <= n; i++)
    for (long j = 1; j <= n; j++)
      for (long k = 1; k <= n; k++)
        if (path[k][j] && dist[i][k] + path[k][j] == dist[i][j]) cnt[i][j]++;
  for (long i = 1; i <= n; i++)
    for (long j = i + 1; j <= n; j++) {
      long ans = 0;
      for (long k = 1; k <= n; k++)
        if (dist[i][k] + dist[k][j] == dist[i][j]) ans += cnt[i][k];
      cout << ans << ' ';
    }
}
