#include <bits/stdc++.h>
using namespace std;
int d[505][505], dd[505][505], mapn[505][505];
long long int e[505][505];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  memset(mapn, 0x3f, sizeof mapn);
  int x, y, z;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    mapn[x][y] = z;
    mapn[y][x] = z;
  }
  memcpy(d, mapn, sizeof mapn);
  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 = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++) {
        if (mapn[i][k] != 0x3f3f3f3f && d[i][j] == mapn[i][k] + d[k][j])
          e[i][j]++;
      }
  for (int i = 1; i < n; i++)
    for (int j = i + 1; j <= n; j++) {
      int ans = 0;
      for (int k = 1; k <= n; k++) {
        if (d[i][j] != 0x3f3f3f3f && d[i][j] == d[i][k] + d[k][j]) {
          ans += e[k][j];
        }
      }
      printf("%d%c", ans, (i != n - 1 ? ' ' : '\n'));
    }
  cout << endl;
  return 0;
}
