#include <bits/stdc++.h>
using namespace std;
int n, m, g[505][505], f[505][505], tot[505], ans[505][505];
int main() {
  scanf("%d%d", &n, &m);
  memset(g, 0x3f, sizeof(g));
  memset(f, 0x3f, sizeof(f));
  for (int i = 1; i <= n; i++) f[i][i] = 0;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    g[u][v] = g[v][u] = f[u][v] = f[v][u] = min(g[u][v], w);
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        f[i][j] = f[j][i] = min(f[i][j], f[i][k] + f[k][j]);
  for (int i = 1; i <= n; i++) {
    memset(tot, 0, sizeof(tot));
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        if (f[i][k] + g[k][j] == f[i][j]) tot[j]++;
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        if (f[i][k] + f[k][j] == f[i][j]) ans[i][j] += tot[k];
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      if (i == j) continue;
      if (f[i][j] >= 0x3f3f3f3f - 100) ans[i][j] = 0;
      printf("%d ", ans[i][j]);
    }
  printf("\n");
}
