#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int maxn = 505;
int check[maxn][maxn], cnt[maxn][maxn], f[maxn][maxn];
int n, m, x, y, z, d[maxn][maxn], e[maxn][maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) d[i][j] = (i == j ? 0 : inf);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &x, &y, &z);
    d[x][y] = d[y][x] = z;
    check[x][y] = check[y][x] = 1;
    e[x][y] = e[y][x] = z;
  }
  for (int k = 1; k <= n; ++k)
    for (int i = 1; i <= n; ++i)
      if (d[i][k] != inf)
        for (int j = 1; j <= n; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      for (int k = 1; k <= n; ++k)
        if (check[k][j] && d[i][k] + e[k][j] == d[i][j]) ++cnt[i][j];
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j)
      for (int k = 1; k <= n; ++k)
        if (d[i][k] + d[k][j] == d[i][j]) f[i][j] += cnt[i][k];
  for (int i = 1; i <= n; ++i)
    for (int j = i + 1; j <= n; ++j) printf("%d ", f[i][j]);
  printf("\n");
  return 0;
}
