#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 505;
int d[maxn][maxn];
int e[maxn][maxn], cnt[maxn][maxn];
void folyd(int n) {
  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]);
      }
}
int main() {
  int n, m;
  memset(e, inf, sizeof(e));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i == j) {
        d[i][j] = 0;
      } else {
        d[i][j] = inf;
      }
    }
  int a, b, w;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &a, &b, &w);
    e[a][b] = e[b][a] = w;
    d[a][b] = d[b][a] = w;
  }
  folyd(n);
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        if (d[i][k] + e[k][j] == d[i][j] && e[k][j] != inf) cnt[i][j]++;
      }
    }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int res = 0;
      for (int k = 1; k <= n; k++) {
        if (d[i][j] == d[i][k] + d[k][j]) res += cnt[i][k];
      }
      printf("%d ", res);
    }
  }
  return 0;
}
