#include <bits/stdc++.h>
using namespace std;
const int maxn = 505;
const int inf = 0x3f3f3f3f;
int n, m;
int g[maxn][maxn];
int d[maxn][maxn];
int cnt[maxn][maxn];
int ans[maxn][maxn];
int main() {
  int a, b, c;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (i != j)
        g[i][j] = inf;
      else
        g[i][j] = 0;
  while (m--) {
    scanf("%d%d%d", &a, &b, &c);
    g[a][b] = g[b][a] = min(g[a][b], c);
  }
  memcpy(d, g, sizeof g);
  memset(cnt, 0, sizeof cnt);
  memset(ans, 0, sizeof ans);
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        if (i != j && k != j)
          if (d[i][j] != inf && d[i][k] + g[k][j] == d[i][j]) cnt[i][j]++;
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
        if (d[i][j] != inf && d[i][k] + d[k][j] == d[i][j])
          ans[i][j] += cnt[i][k];
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) printf("%d ", ans[i][j]);
  puts("");
  return 0;
}
