#include <bits/stdc++.h>
using namespace std;
int N, M, d[505][505], a[250005], b[250005], c[250005], ans[505][505];
int main() {
  scanf("%d%d", &N, &M);
  memset(d, 63, sizeof(d));
  for (int i = 0; i < M; ++i) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  }
  for (int i = 1; i <= N; ++i) d[i][i] = 0;
  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 i = 0; i < M; ++i) {
    for (int k = 1; k <= N; ++k) {
      ans[a[i]][k] += (int)(d[a[i]][k] == c[i] + d[b[i]][k]);
      ans[b[i]][k] += (int)(d[b[i]][k] == c[i] + d[a[i]][k]);
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = i + 1; j <= N; ++j) {
      int sum = 0;
      for (int k = 1; k <= N; ++k)
        sum += ans[k][j] * (d[i][j] == d[i][k] + d[k][j]);
      printf("%d ", sum);
    }
  }
}
